DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Sometimes you may want to have an entire category of your blog with nofollow links, for exemple if you’re linking to a lot of external resources. Here is a quick and easy recipe to do so. Enjoy!

Simply copy the code below and paste it on your functions.php file. Don’t forget to set the desired category ID on line 3.

function nofollow_cat_posts($text) {
global $post;
        if( in_category(1) ) { // SET CATEGORY ID HERE
                $text = stripslashes(wp_rel_nofollow($text));
        return $text;
add_filter('the_content', 'nofollow_cat_posts');

Thanks to Sagive for submitting this function!



  1. I was searching for this all over the place. I always got some troubles with blog links , your site looks like a great resource for further reference.
    Thanks a bunch

  2. Hi,

    How can I add rel nofollow to links for posts in a specific tag (instead of category)?


  3. …solved myself actually. Just use “has_tag” instead of “in_category”.


  4. Previously when I used genesis theme, there used to be lots of duplication of the titles in every page indexed by Google. I had to nofollow the links in order to have a control over that. Can I use this for genesis as this looks to be very simple as compared to digging into the genesis child theme and making changes there.

  5. im having issues while doing this i get fatal error when i add this to my functions.php file ! please tell me where can i get it right !

Leave a Comment

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