Want to add nofollow attribute to all links in a specific category? Add the following code to the functions.php file of your current activated theme or you can also add the below code inside your site-specific plugin.
1 2 3 4 5 6 7 8 9 10 11 | /** * Add nofollow attribute to all links in a specific category. */ function fwm_all_nofollow_category_posts( $text ) { global $post; if( in_category(1) ) { $text = stripslashes( wp_rel_nofollow($text) ); } return $text; } add_filter( 'the_content', 'fwm_all_nofollow_category_posts' ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.