Commenting on WordPress

Remove Nofollow for Comment Authors with a Simple Function

| 16 Comments

Back in the day, it was very simple; every link counted for something. However, in 2005, in an effort to battle spam, Google introduced the nofollow attribute to battle people who were leaving comments everywhere they could so that they could keep building their backlinks. The idea of the nofollow attribute is that commenters can still leave their URL, but Google ignores it in terms of PageRank, so it doesn’t have a negative impact on your site if the link leads to a spammy site.

That all sounds well and good, but in the eyes of many (myself included), it’s a case of punishing everyone for the actions of the few. There are still millions of legitimate bloggers who rely on commenting to help build their reputation online and nofollow only hinders that.

There are a few initiatives that aim to help bloggers make the most out of building community by commenting. One of those is CommentLuv (which you will note, is installed here on Do It With WordPress) which allows commenters to leave a link to one of their most recent posts as well as a link to their main homepage.

Another initiative is to remove the nofollow attribute from WordPress, which is included in comment author links as standard. There are a few ways to do this; I don’t recommend editing the core commenting files, because as soon as WordPress is upgraded, you lose your changes.

A second way is to install a plugin that will do it for you. That’s fine and will work OK, but for me, I like to have complete control over my site, so I like to use functions where possible. I finally found a function which does this for you; all you need to do is copy the snippet below into your functions.php file. You can check that it’s worked by looking at the page source both before and after and looking for the removal of rel=”nofollow” from the comment author’s links.

You can also take it a step further and remove the nofollow attribute from all links related to comments, such as links that are left within the comment text itself. To do that, use the following function instead:

Are you in nofollow camp, or have you seen the light and come over to the dofollow camp? How have you handled making your site dofollow?

Categories: Blogging, Code & Snippets | Permalink

What next?

Hire me

If you couldn't quite manage this yourself, find it too intimidating, or just don't have the time to do it, you can always hire Dave to do it. Please get in touch so that we can discuss your needs.

Leave a comment

If you have a question, update, or comment about the tutorial, please leave a comment. I try and respond to every comment, though it may take a few days, so please check back soon.

Let a WordPress Expert help you

Do you want to try this, but feel like you need a helping hand, in case something goes wrong? My service, The WP Butler, gives you access to WordPress expertise whenever you need it. Better yet, I'll keep your site backed up, updated and secure, so that you don't have to worry about it. It's all part of the service. Use coupon DIWW and save 15% on all plans.

Visit The WP Butler

Author:

Dave has been tinkering with WordPress for many years, and he now shares his WordPress knowledge here on Do It WIth WordPress to help others realise its impressive power. He can also be hired to help with your WordPress needs. Dave, who is British, is married to his best friend, Marti, with whom he has a beautiful daughter, Ellie. When he's not dabbling with WordPress, he's probably eating Triscuits or hummus, watching an indie film or British TV show, spending time with friends or family, or exploring the world.

16 Comments

  1. Another way to promote your blog would be to use a readable font. That embossed thing you use is excruciatingly annoying to read.

  2. Wow it was very easy and simple step.. actually my blog is dofollow but i was using Plugin for this in my blog.. Let me do this change and remove that plugin. Thanks

    • Thanks Vincent. I was using the plugin too, but for such a simple action, I was sure there had to be a function that could handle it. It wasn’t easy to come by, but I got there in the end. Hope it works for you. Let me know if you hit any trouble

  3. Great tips. However, what will happen when we upgrade WP in the future? Will we lost the changes and have to make our hands dirty again by editing the code?

    • When you need to upgrade WordPress, your functions.php file will be fine. However, if your theme gets updated (if its from the official WordPress directory), then it will overwrite your functions.php file. That’s why i always use a funcionality plugin with my sites, so that upgrades never affect my customizations (tutorial on that coming soon).

      • Dave, great article you shared mate.

        Janice, I believe using Child theme will keep all your modifications intact since child theme has separate functions file. I didn’t know about using Child theme before but when I tried it, it’s fun and will save you from all future updates whether you’re updating WP core script or theme. I hope that helps. :)

  4. You made me aware that commenters were getting no juice. I may use the code some day, but for now I just activated the plugin Remove Nofollow. Thanks!

  5. If you don’t feel safe playing around the backend coding of WordPress, you can always use a plugin to remove nofollow attribute for you.

    I’d suggest using the Semiologic plugin found here:
    http://www.semiologic.com/software/dofollow/

    It still works on the latest WordPress 3.2.x version.

  6. I copy/pasted the first script and it gave the following error instead of displaying the author names for both those that did and didn’t supply a URL:
    Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses at offset 5 in {My test site}/wp-content/themes/twentyten/functions.php on line 528
    Line 528 of my theme’s function.php is line 7 of your script.

    I did, however, find it easy to remove nofollow from comment author names by editing the WP core. In /wp-includes/comment-template.php line 155 (inside the get_comment_author_link function), omit “nofollow” from the relation attribute. Since it is a core file adjustment, you’ll need to reapply the change each time WP updates that file, but it’s a quick change.

    The second script gives the same error as the first by replacing the comment author and the comment itself whether or not either have URLs. I’ve yet to find a solution to remove nofollow from comments, but I’ll keep looking. Like you, I prefer hard-coding small adjustments instead of installing plugins.

    P.S. I only just found your site tonight and it’s definitely worth a bookmark. Good effort.

    • Thanks for your comment. I’m not sure what the issue with the function on your site is without being able to see it, but I avoid editing the WordPress core at all costs, not because I’m afraid of messing something up, but just because it’s unwise and as you rightly pointed out, it’s something you have to remember to do every time you update WordPress, which is just another thing to worry about IMO. I’d try and see what the problem is with the function and repair it. If you find a solution, I’d be grateful if you’d post it here in case other people are having the sam problem. Thanks!

  7. I’m now using CommentLuv to manage Do Follow. I’m assuming that takes the place of either the remove No Follow code or the other plugins. Is that accurate?

Leave a Reply