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
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