Add nofollow attribute to category specific links

Adding this snippet to the functions.php of your wordpress theme will add the nofollow attribute to category specific links within the_content.

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');

Comments  Leave a Reply

  1. How to add nofollow attribute just to specific link?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!