Tutorial: How to Remove link rel=’prev’ and link rel=’next’ from WordPress Head

How to Remove link rel=’prev’ and link rel=’next’ from WordPress Head (in WP 3.0+)

WordPress, in its default state, prints a lot of excess code to the head section of webpages. One element that always annoyed me were two entries that always appeared:

<link rel='prev' title='' href='' /> <link rel='next' title='' href='' />

These entries are recommended for web usability for disabled persons–consider that before removing them. We were looking for a way to lean up our pages, though, so we thought we’d like to remove these entries. There are some outdated instructions in WP forums that will not work in WP 3.0; we tried several approaches, but nothing worked.

In your WordPress template, you’ll find your functions.php file. Open that file and enter the following line.

remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );

This “filter,” as it is called, will tell WordPress not to generate the link rel=’prev’ and link rel=’next’ lines in the WordPress head.

Just a note on why those outdated instructions wouldn’t work with WP 3.0. The filter we created instructs WP to turn off the action titled “adjacent_posts_rel_link_wp_head.” Our commands works in WP 3.0 and above because the former action prior to 3.0 was titled “adjacent_posts_rel_link.”


21 replies
  1. Tanja
    Tanja says:

    Thank you, thank you, thank you…!!! You a) answered a question I’ve been asking myself everytime I looked at my server logs, and b) told me how to eliminate the problem. I just didn’t understand where all those referrers to an actually totally unimportant rant I wrote came from; the post I wrote before seems to have turned into the most popular Google search result of my blog, so there were a lot of those, and I just couldn’t find it anywhere on the page until just now when I looked at the source code of the rendered page. A somewhat unexpected cause; especially since I have a hard time seeing the point of this WP function. What good does it do if there is no visible link on the page? Anyway, thanks for posting, big help!


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *