How to remove “prev, next, shortlink” from wp_head()?

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

3 s
3

One 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).

Leave a Comment