Home / category / Add nofollow attribute to category specific links
  • How to Add nofollow attribute to category specific links

    add-nofollow-attributes-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.

    ( click code to copy )

    wordpress snippet : PHP

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

    ( WordPress codex functions, hooks, in this snippet. )

    the_content, in_category, add_filter, wp_rel_nofollow, _n, wp,
  • nooblord

    How to add nofollow attribute just to specific link?