Forums

rel="nofollow" To Links Inside Post Of A Category? (4 posts)

  1. Roseate
    Member
    Posted 6 months ago #

    Hi,

    How can I make the links inside a post to rel="nofollow", but for posts of a one/some category?

    Thanks,

  2. Kafkaesqui
    Moderator
    Posted 6 months ago #

    You could add the following to your theme's functions.php (if it lacks one you can add it; make sure the first line of the file is <?php and the last is ?>). Edit 1 in in_category(1) to the category ID # you want it to work on:

    function nofollow_cat_posts($text) {
    	global $post;
    	if( in_category(1) ) {
    		$text = stripslashes(wp_rel_nofollow($text));
    	}
    
    	return $text;
    }
    add_filter('the_content', 'nofollow_cat_posts');
  3. Roseate
    Member
    Posted 6 months ago #

    Done .... Thanks Kafkaesqui :)

  4. ibnuasad
    Member
    Posted 2 months ago #

    I've recently developed a plugin called "Nofollow Links in Posts".

    Basically the plugin enables you to add nofollow into links in posts within a specified categories. It also allows you to filter only links in posts older than "X" days to be added with the nofollow attribute.

    Hope this helps ;)

Reply

You must log in to post.

About this Topic