admin管理员组文章数量:1415145
I'm using these filters to clean the head of my theme:
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
remove_action('wp_head', 'locale_stylesheet');
remove_action('wp_head', 'noindex');
remove_action('wp_head', 'wp_print_styles');
remove_action('wp_head', 'wp_print_head_scripts');
However, I can't seem to get rid of these:
<link rel='prev' title='Top Menu Item 1' href='http://localhost/test/test-prev.html' />
<link rel='next' title='Internal title test default title' href='http://localhost/test/text-next.html' />
<link rel='shortlink' href='http://localhost/test/?p=528' />
I'm using these filters to clean the head of my theme:
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
remove_action('wp_head', 'locale_stylesheet');
remove_action('wp_head', 'noindex');
remove_action('wp_head', 'wp_print_styles');
remove_action('wp_head', 'wp_print_head_scripts');
However, I can't seem to get rid of these:
<link rel='prev' title='Top Menu Item 1' href='http://localhost/test/test-prev.html' />
<link rel='next' title='Internal title test default title' href='http://localhost/test/text-next.html' />
<link rel='shortlink' href='http://localhost/test/?p=528' />
Share
Improve this question
asked Sep 20, 2011 at 14:53
N2MysticN2Mystic
3,1937 gold badges47 silver badges72 bronze badges
1
|
3 Answers
Reset to default 1One shouldn't remove them. They are important for search engines like Google.
One can remove them like this:
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
Here are some additional explanations why they should not be removed and how this effects search engines:
- Core Code insertion
- The related trac ticket
- Google Webmaster Central Article about changes & impact on SEO
In case one removes them, one should really add its own (in case one has changed their links and they are not pointing to the correct urls, that the pagination points to).
Add these to your list:
<?php
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
wp-includes/default-filters.php
should be your first stop to check out what WordPress is using its own hook system for.
I've been struggling with this for a while, too, and it appears you should remove action with exactly the same parameters it was added.
so for me the following like in functions.php did the job:
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10,0);
I'm using WP 3.3.1
本文标签: theme developmentHow to remove quotprevnextshortlinkquot from wphead()
版权声明:本文标题:theme development - How to remove "prev, next, shortlink" from wp_head()? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745205443a2647618.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_print_styles
orwp_print_head_scripts
. A lot of plugins are going to rely on those to enqueue styles and scripts. Your theme will probably be enqueuing its own styles and scripts as well. – chrisguitarguy Commented Sep 20, 2011 at 16:47