Hacking WordPress: Removing Nofollow from the Source
I had an intermittent problem with my comments where the actual comment text was not appearing. I finally tracked it down to the Dofollow plugin and removed it today. I still actually want to rid my site of rel=nofollow on authors and comments, though. If you would like to read why, here’s a post on what rel=”nofollow” is and how it works.
NOTE: Before you edit any code in WordPress, be sure to back it up first! I’m not responsible if your site gets hosed up.
![]()
Today I dug into the code and actually identified in WordPress core code where the nofollow edit is made. You can make these edits as well if you’re hosting your own WordPress installation.
Removing WordPress rel=nofollow on Authors
For the author link, the line of code is in wp-includes/comment-template.php (WP 2.3 or older: line 48, WP 2.5: line 114, WP 2.6: line 116). Replace
$return = "<a href='$url' rel='external nofollow'>$author</a>";
with this:
$return = "<a href='$url' rel='external'>$author</a>";
Removing WordPress rel=nofollow on Comment Text
Links in the actual comments are a little tougher to find. However, I was able to track down where the filter was applied in wp-includes/default-filters.php (WP 2.3 or older: line 125, WP 2.5+: line 154). To disable the filter, you need only to remark the link out by putting two forward slashes in front of it. Edit
add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
like this:
//add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
Voila! No more punishing your users for generating great content on your blog! The advantage of doing it this way is that you’re not applying more code later in a plugin to remove the code that was there in the first place. The disadvantage of doing it this way is that you’ll have to update it each time you upgrade WordPress on your site.
Happy Hacking!