Adding nofollow attribute to your WordPress blogroll

Written by on March 14, 2010 in Seo, WordPress - 14 Comments

If you want to add the “nofollow” attribute to any link in your blogroll (and you should do this if your links come from paid sources or if you want to limit the flow of pagerank) without using a plugin here’s quick tutorial as to how you can add this attribute to your WordPress installation (WordPress 2.9+).

Note: If you use a version older than WordPress 2.9 this method will not work. Check this website for a method that works with older installs, or upgrade to the latest version.

Warning: before you start please make a backup of the files that you’re going to edit.

How to add nofollow to WordPress Blog links

If you’re a beginner you’ll get your hands a little dirty but it’s not so hard afterall, you’ll see.

1. Navigate to your wordpress install folder and open the file /wp-admin/includes/meta-boxes.php.
2. Go to line 675 and you should see somethink like this:

<tr>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </th>

3. Now, just before this line add this piece of code:

<tr>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('Seo') ?> </th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('nofollow') ?> </span></legend>
<label for="nofollow">
<input class="valinp" type="checkbox" name="nofollow" value="nofollow" id="nofollow" <?php xfn_check('Seo', 'nofollow'); ?> />
<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('nofollow') ?></label>
</fieldset></td>
</tr>

Save your file and go to the Links section from your WordPress Dashboard. If you edit or add a new link, you’ll see that the “Seo” option with the “nofollow” attribute is the first attribute in the Link Relationships (XFN) section.

Hope you’ve enjoyed this. Cheers.

If you enjoyed this post please consider sharing it.

14 Comments on "Adding nofollow attribute to your WordPress blogroll"

  1. octavian April 19, 2010 at 9:51 pm · Reply

    Hi! Thanks for sharing this – it’s the first article I find on the topic that relates in some way to post-WP2.9 development. I’m currently working with WP2.9.2 as the latest WP build and although adding the code does the trick and inserts in the link section of the dashboard the nofollow rel in the relationship panel, it does not stay checked after updating the link. Nor does it do the trick, since the rel column in the edit link panel stays empty. I’d be grateful if you shared your thoughts on how to overcome that. I’m kind of new to this stuff, I can follow directions pretty easily, but thinking it up myself does not yet work. Thanks again!

  2. Skat April 20, 2010 at 2:24 am · Reply

    Hi, thanks for noticing that. By mistake I wrote line 676 instead of 675. I’ve changed the error now.

    So, go on line 675 and just before it (see the example again) add the code again and please tell me if it worked.

    Cheers.

  3. octavian April 20, 2010 at 5:10 am · Reply

    Works like a marvel! Thanks for your help!

  4. James May 14, 2010 at 5:17 pm · Reply

    Thanks! Worked perfectly. It is a feature that I have wanted for awhile. Many man thanks!

  5. James May 14, 2010 at 5:18 pm · Reply

    Oops. supposed to have read “many many thanks!”

  6. Wordpress Themes June 22, 2010 at 11:36 pm · Reply

    Amiable fill someone in on and this enter helped me alot in my college assignement. Gratefulness you seeking your information.

  7. Alan September 9, 2010 at 3:34 am · Reply

    Dude, I was using google for this for hours and all other ways of doing this failed but yours didn’t. You are the man! THANK YOU

  8. Yohan Perera September 17, 2010 at 6:27 am · Reply

    This is superb. I hate using plugins for doing every little thing like adding “nofollow” to selected URLs in my blogroll. I Googgled for days to find a solution but all of them were focused on older versions of WordPress and didn’t work for 3.0

    But this solution you have provided here works like a miracle.

    • Yohan Perera September 17, 2010 at 6:37 am · Reply

      Ohhh… Sorry it works for WP 3.0.1 (latest version at the time of this writing) – that’s what I am using… not sure if it works with 3.0

  9. Manny September 30, 2010 at 12:02 am · Reply

    I have WP 3.0.1 and line 675 doesn’t look like that on mine. I’m a total newbie. Please help

    • Skat September 30, 2010 at 2:47 am · Reply

      Hi. In WP 3.0.1 go to line 738 instead and just after that line add the code.

  10. Manny October 1, 2010 at 3:42 am · Reply

    Thank you Skat. :)

  11. matth October 16, 2010 at 8:31 pm · Reply

    works great in wp 3.01. thanks a lot. hey folks dont forget after updating your wordpress to ‘reinstall’ this snippet of code.

  12. TC December 9, 2010 at 12:11 pm · Reply

    Just wanted to pop in and say thanks a bunch for this fix, I can’t believe it isn’t part of the core. Works fine with wp 3.03.

Leave a Comment