Remove the “nofollow” From the Recent Comments


I noticed while testing my own blog that the Recent Comments widget in the footer of this site has a nofollow attribute for all the authors’ links. It makes sense to have this, but at the same time I didn’t want the nofollow on my own comments.

Here is how I removed it.

Why Is The nofollow There?

One of the easiest method to build your SEO with backlinks back in the days was to use comments on blogs, and this increased the number of spam comments.

The purpose of this attribute was to make SEO manipulation via blog comments less effective, so introducing that in WordPress comments was supposed to demotivate spammers to use comments to get backlinks. Although it reduced the number of spam comments, some spammers still thought and think today that a nofollow link is better than no link at all.

Should You Remove The nofollow?

You might think that removing the nofollow attribute might encourage readers to genuinely comment on your site. Even if this might be true, you would still not gain any benefits from having spam comments that might bypass some security systems, like Akismet for example, or allowing the crawler to go to the site of a random reader that you’ve never seen before. For this reason, I still think that you should not remove it.

But why did I remove it then? Well, I didn’t, not entirely at least. I removed it only from commenters that I personally trust and know.

I wrote a little snippet that removes the nofollow attribute only on comments that I write personally. I will probably expand the list of trusted commenters with time. To begin with, I think that trusting myself is a good first step.

How Do I Remove The nofollow on My Own Comments?

Add this script at the end of your functions.php file in wp-content/themes/your-child-theme-name/:

Make sure to replace Your Name with the name shown on your WordPress profile.

3 replies
  1. Shaman Jungle
    Shaman Jungle says:

    I’m adding your snippet and it just doesn’t work. Any ideas of what could be wrong? Does it work on your side? What exactly do you use for the $author variable?


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply