I was trying to remove the rel=prev and rel=next tags from my website as my SEO gut suggested. I found those functions which perfectly do the magic:

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

however, after a while my SEO guy suggested to leave it on a categories section where over there it's necassary as far as SEO.

is there a simple way of implementing the rel=prev and rel=next tags only on a categories pages?, e.g: www.website.com/category/category-name and remove it from all other post types? (post, page, homepage etc etc)

Thanks, GIl


3 Answers 3


Not entirely sure if I agree with the explanation of your SEO guy as rel=prev and rel=next are used for paginated archives.

Of course categories can be one, but also your blog if it'd contain multiple pages.

Anyways, here's what I'm currently using:

remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );

add_action( 'wp_head', 'cor_rel_next_prev_pagination' );
 * Pagination with rel="next" and rel="prev".
 * @link wp-includes|default-filters.php
 * @link http://core.trac.wordpress.org/ticket/18672 Implement rel="prev" and rel="next" for archives
 * @link http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html Pagination with rel="next" and rel="prev"
function cor_rel_next_prev_pagination() {
  global $paged;
  if ( get_previous_posts_link() ) {
  <link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>">
  if ( get_next_posts_link() ) {
  <link rel="next" href="<?php echo get_pagenum_link( $paged + 1 ); ?>">

Edit: also I believe start_post_rel_link is no longer being used.

  • Hi Cor, I understand what you are saying and you are absolutely right, however in my case we don't have a blog and what happens is that we used many posts as a "static post" (we should have used pages instead but we didn't know) and they present a static content that has nothing to do with other posts, therefore it shouldn't have the "next" and "prev" tags which now exist and are bad for our SEO as Google refer to it as piece of content that it's part of more content.
    – gil hamer
    Commented Apr 2, 2012 at 15:16
  • Does this code takes care of it?Does this code takes care of it? Thanks alot
    – gil hamer
    Commented Apr 2, 2012 at 15:24
  • Hello @gilhamer, I understand. I can't promise you anything of course, but I'm pretty sure it'll work. (do check you site's source to be sure)
    – user5424
    Commented Apr 3, 2012 at 6:28

I think you can wrap your hooks into template_redirect hook, which is fired before sending content to browser, something like this:

add_action( 'template_redirect', 'wpse_47638_remove_rel_link' );
function wpse_47638_remove_rel_link() {
    if ( is_category() )
    remove_action('wp_head', 'start_post_rel_link', 10, 0 );
    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

Try the is_category function. You should be able to add a high priority action to wp_head that checks the result, then conditionally runs the two statements you have above to remove the actions that assign REL to the links.

I'm honestly not sure if this method is operable this early in the WP lifecycle, but failing that, grab the URL using _SERVER and test for a category pattern.

  • Thanks charlie, I tried putting conditional statements in my functions.php but it didn't work
    – gil hamer
    Commented Apr 2, 2012 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.