How to Make Author Comment Links Do-Follow in Wordpress Without Using a Plugin

by Christy Correll on May 3, 2010 in Wordpress Thesis Hacks

You don't need a plugin to make your author comment links dofollow. All you need to know is which single word to delete in the Wordpress core files.

Because you don’t need a plugin to remove one word of code for you

By default, Wordpress nofollows author comment links. For those of us who would like to reward our commenters with a little link love, there are plenty of plugins available that will remove the nofollow attribute from these links. However, you probably already have a couple of plugins installed that you cannot live out. Add a few more, and you will notice that your blog isn’t running as fast as it used to. This would be bad not only for usability, but due to the fact that page load time is becoming an increasingly important search engine ranking factor. Need more reasons to limit your use of plugins as much as possible? Here’s just two of many: 1) Plugin authors can stop supporting Wordpress upgrades at any time. 2) Plugins sometimes will break a new theme installation.

So don’t use a plugin if you don’t have to. Especially if all you need to do instead is remove one word of code, which is all we need to do to remove the link condoms from our author comment links. The thing is (and brace yourself if you have never done this before), we are going to have to alter one of the core Wordpress files. I understand how this can be a little scary if you have never done it before (and for good reason, because you can break your entire blog by leaving out a simple bracket when you touch the php), but we are only going to remove a single word in this instance so it will be okay. And I’m going to hold your hand.

Wide awake and ready to go for it? Great! Here’s what to do:

1. Via ftp or however you are most comfortable accessing your core files, open up the WP-includes folder and make a backup copy of the file named “comment-template.php”.

2. Locate this bit of code for the “get_comment_author_link” in the working copy of the file:

$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";

3. Delete the word “nofollow” and the preceding space so that you are left with this:

$return = "<a href='$url' rel='external' class='url'>$author</a>";

4. Save your file.

5. Check the source code of a page with author comment links (or use a tool like SEO Firefox that highlights nofollow links) to ensure your comment links are now sharing link juice.

Voila, that’s it!

Final thoughts

You should note that since you altered a core Wordpress file (version 2.9 in my case), you will need to repeat this process when you upgrade Wordpress. If anyone knows how to do this by altering the custom functions file in Thesis, I would love to know as this would eliminate repeating this process each time I upgrade Wordpress.



Have you subscribed to this blog? If not, you may easily do so using the rss feed reader of your choice. Or subscribe via email to have new posts delivered directly to your inbox.

{ 4 comments… read them below or add one }

1 Lanna August 16, 2010 at 6:41 pm

Hello Christy,

Did you know that you have saved me a lot of time? Thanks a million!

I’ve been searching the whole evening in Goolge just looking for an answer like your post: “make wordpress dofollow without a plugin?” And your post is the only one that gave me the right answer. All others suggested a plugin which is not what I want. I don’t want to use too many plugins just like you.

For your final thought… I think I will just copy and paste comment-template.php over. That should not take long, right?

2 Christy Correll August 27, 2010 at 3:37 pm

Yes, but make a backup of the original … just in case.

3 blogjunkie September 3, 2010 at 8:09 pm

Great tip! Unfortunately every time you do an upgrade you’ll lose the changes.. so it may still be best to use a plugin :)

4 Ari Herzog September 5, 2010 at 7:47 pm

I asked that question over on the Thesis forums, and here’s the answer to replace the plugin with a custom function:

function do_follow_commenters($output) {
return str_replace(” rel=’external nofollow’”, “”, $output);
}
add_filter(‘get_comment_author_link’, ‘do_follow_commenters’);

Leave a Comment

Previous post:

Next post: