Hacking WordPress: Removing Nofollow from the Source

html code
Reading Time: 2 minutes

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).


$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.


add_filter('pre_comment_content', 'wp_rel_nofollow', 15);

to 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!


  1. 1
  2. 3

    Thank you for this post. I have been going nuts trying to find where to remove the nofollow. You are a wonderful resource.


  3. 5

    Thanks Douglas. I installed the dofollow plugin, but then removed it again as it was not quite working correctly.
    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.

  4. 7
  5. 8

    Gosh, this is such an easy fix, I keep reading it thinking I’m not getting something.

    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!!

  6. 9
  7. 10

    This is great.

    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!


  8. 11

    I just thought I’d mention, the second part should be possible without commenting it out. You should be able to use the following: remove_filter('pre_comment_content','wp_rel_nofollow'):
    Stick that in your template or in a plugin 🙂

  9. 12
  10. 13

    Thanks for this. I’ve been reading a lot of people who are doing this lately – but you’re the first person who’s told me how. 😉 I followed along, modded my files, and am saving this for when I do upgrades so I have it. 😉

  11. 14
  12. 16

    Me and a friend were just talking yesterday about getting rid of the nofollow and we thought that it was just something that we would have to live with.

    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


  13. 17

    I just upgraded my WordPress Blog – noticed I needed to “rehack” my site. Thanks for having these instructions here. They helped me once again

  14. 18

    Half the fun of posting comments is so that all involved to get a link back to your own website. Thanks for letting others get this benefit.

  15. 19

    Making the change:

    //add_filter(‘pre_comment_content’, ‘wp_rel_nofollow’, 15);

    The old comments continues with nofollow …

    How can I to remove this?

  16. 20
  17. 21

    I’m really confused on this area. I do think that the nofollow is not the right way to do it and it ruins it for a lot of other people. However many blogs I used to read got spammed so badly.
    Hmmm strange my first comment didn’t get posted. How come ?

  18. 22
    • 23

      Hi Lufti,

      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.


  19. 24

    Awesome! Thank you! I am a fairly new blogger, and was trying to find this in the code myself, but failed :). So I installed Dofollow, but then, after it was correctly activated etc. the no follow code was still showing up in the comment html when people tried to leave links in their comments! ARGH! Thank you SO much! I just edited my code and am off to uninstall Do Follow now. Found you through a Google search.

  20. 25
  21. 26

    Thanks Douglas for this nice tip I think do follow is the way to go, and about Page Rank issues there are many PR6 do follow blogs around so personally I don’t think well moderated comments spoil Page Rank.

  22. 27
  23. 28
    • 29

      I honestly don’t believe a single point he’s made, Bloke. Since I moderate my comments and verify the source, I do a good job of keeping the spammers out and having great conversations with my readers. They deserve credit for those conversations!

      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.

  24. 30

    It’s something that I’ve often pondered myself.

    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.

    • 31

      Hi Bloke,

      I found this in-depth article over at SEOMoz:

      Search engines cannot afford to remove all pages that are linked to by spam pages for precisely this reason – intelligent spammers point their links to themselves, their competition and their community. It would take significant effort to reveal which pages are spam and which are natural, which is exactly the point of these more modern, sophisticated artificial link schemes.


  25. 33
  26. 34
  27. 35

    how come i still can’t remove the rel=”nofollow” in the comments area? i already put the // in the 2nd part where you advised.

  28. 37
  29. 38
  30. 39
  31. 40

    What about removing nofollow from pages? What file would we edit to remove nofollow from all pages and posts?
    We tried a few plugins to do this with no success…..

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.