Auto adding rel nofollow to WordPress posts

If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

From an SEO perspective, there are multiple reasons that you want to use rel=nofollow on your links.

rel=nofollow basically tells Google not to pass ‘link juice’ to the target of the link.

Originally, you would want to do that to stop passing on your link juice, when you would want to keep it for your internal links. But now there is a more compelling reason, with so many blogs effectively selling links, if your blog posts have lots of outbound links to help the reader, then Google could inadvertently think you are actually a spammy blog.

As many of my blog posts reference third party sources, I didn’t want google to get the impression that the blog posts are there just to provide SEO to someone else and get caught up as a spammy blog.

Of course, you can manually add rel=nofollow to each link in a post, but I wanted a way of just setting all links in the content of a post to be rel=nofollow.

This simple bit of code added to functions.php does the trick for me

//* force no follow in posts 
function myfunc_nofollow($text) {
global $post;
if( is_single() ) { 
$text = stripslashes(wp_rel_nofollow($text));
return $text;
add_filter('the_content', 'myfunc_nofollow');








Leave a Reply

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