Set comments and post links to DoFollow in WordPress

When the Google bot is crawling a website it’s also looking for external links pointing to other websites. If these links are set to “dofollow” then the link juice gets passed and contributes to a good page rank and a rise in SERP. The “nofollow” attribute is a way for webmasters to tell search engines “not to follow a certain link”.

Pros and cons:

DoFollow links in content will give the destination website a boost but can also attract a Google penalty if it looks like a paid link or it points to spammy and untrusted content.

DoFollow links in comments can encourage people to leave a comment and engage the conversation but it can also fill your comment thread with spam.

The dofollow vs nofollow talk is way more complex, but those are the main issues.

Although WordPress isn’t set by default to insert the rel=”nofollow” attribute to the links that appear in post content, you may have used plugins to achieve that or maybe you manually added nofollow attributes to the links in your posts for SEO reasons and now you want them all clean.

To remove the nofollow attribute from post content links, add the following code to the functions.php file:

function remove_nofollow($string) {

$string = str_ireplace(‘ rel=”nofollow”‘, ”, $string);

return $string;

}

add_filter(‘the_content’, ‘remove_nofollow’);

If you want to remove the nofollow attribute from post content links and comment links, use this line:

function remove_nofollow($string) {

$string = str_ireplace(‘ rel=”nofollow”‘, ”, $string);

return $string;

}

add_filter(‘the_content’, ‘remove_nofollow’);

add_filter(‘comment_text’, ‘remove_nofollow’);

If editing isn’t your thing or you don’t have access to your functions.php file, you can also use a plugin to do the work. For example, the Smart DoFollow plugin will automatically remove nofollow attribute from comment links that have more than a certain amount of characters or from comments from a certain user that has a number of comment approved. Always remember that a dofollow blog will attract a certain amount of spam and you should be ready to deal with it.

Do you want to build a flawless website?