Hacking WordPress: Removing Nofollow from the Source
Happy New Year! Marketing Technology finds and reports on the latest technology that will enable your business to effectively market to your audience, for acquisition or retention strategies. Subscribe now the Marketing Technology Blog RSS feed or to the Marketing Technology Email to have new content sent directly to your inbox. You'll also find my other business blog helpful, Social Media Domination.
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!

(would be nice if they just coded it in as an option to turn on/off from the options panel)
Dotty
I did a google search and then found your blog. I’ll try out the WP hack later. Hopefully it will get more people commenting on my blog.
I noticed the same thing and that’s why I made this change! I do think it supports more folks commenting!
Regards,
Doug
May even do a short post on my site and refer them here…
Jeff,
WordPress Guides
I installed LinkLove yesterday to remove the nofollows. This is a (simpler) no-frills approach. I’ll have to keep it bookmarked, just in case. Thank you!!
I wish I could make the same change, but my blog is hosted on WordPress.com (see it here), so unfortunately I cannot edit anything (even editing just the CSS costs money, not to talk about editing themes).
Might go for another host, then I will definitely follow your lead on this!
Jerome
remove_filter('pre_comment_content','wp_rel_nofollow'):Stick that in your template or in a plugin
That’s a nice hack! Now I can do this without plugin
Thanks, Douglas
Misha
Mapquest
Then today he sends me this great post!!
I will be making this change immediately. I only hope every blogger out there reads this post
thanks
michael
Dotty
//add_filter(’pre_comment_content’, ‘wp_rel_nofollow’, 15);
The old comments continues with nofollow …
How can I to remove this?
Hmmm strange my first comment didn’t get posted. How come ?
If you do not moderate comments and allow link spam into your sites… YES… you can definitely damage your Pagerank. I would not recommend it without moderating comments carefully.
Cheers,
Doug
Thanks-
http://mixedmarketarts.com/2008/02/12/top-9-reasons-dofollow-can-hurt-your-blog/
Do you believe removing “nofollow” leeches our pagerank? I would be interested in your opinion on that.
…BB
I think you’re similar to me, we don’t just write on our blog, we like to engage! That means we pay attention to the comments - not simply letting them run amuck.
Will “dofollow” blog comments linking to irrelevant or poorly ranked blogs end up hurting our pagerank?
Hmm, I hope not. I’m really not sure myself and there doesn’t seem to be a lot of discussion out there about it.
Only time will tell I suppose. Let me know if you find any more information will you please?
Thanks Doug.
I found this in-depth article over at SEOMoz:
Doug
Cheers,
…BB