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
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:
Edit: also I believe
start_post_rel_link
is no longer being used.I think you can wrap your hooks into
template_redirect
hook, which is fired before sending content to browser, something like this: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.