Do you need a hack for your blogroll to be able to control to your blogroll and add a “nofollow” attribute to it? Don’t have time to scour the WP Plugin resources to find something which does this? I’m going to admit – I didn’t have time to check if there is a plugin but thought this is a nice tip anyway just to demonstrate how you can get some more control over your WordPress system if you know how.

And I do…

I call this the “WP Blogroll Gray Hack”, named after the Stomper who first showed me it. Gray H, you know who you are – thanks for this little tip. I owe you a beer. :)

The method I’m going to demonstrate has actually been slightly updated as the original meant losing some of the other XFN options. This version actually adds more to the existing hack and provides a new checkbox to easily add the nofollow attribute.

Here’s the quick how-to guide for WordPress newbies on how you can do this.

The file we’re going to be hacking today is:

/wp-admin/edit-link-form.php

Before we get started, BACK UP YOUR FILE.

Okay, now for step-by-step guide on the Gray Hack:

  1. Open the edit-link-form.php file (yes, I’m making this very easy for newbies and the hard of thinking!)
  2. On around line 28, find the part that says:

    if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
  3. Leave this code alone.
  4. Just above the code, add:

    if ('seo' == $class && strpos($link_rel, 'nofollow') === false) echo ' checked="checked"';
  5. Scroll down and find the line which says:

    <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th?>
  6. Just underneath this line of code, find the opening table:

    <table cellpadding="3" cellspacing="5">
  7. Add the following code just underneath this opening table tag.
    <tr>
    <th scope="row"> <?php _e('seo') ?> </th>
    <td>
    <label for="nofollow">
    <input class="valinp" type="checkbox" name="seo" value="nofollow" id="nofollow" <?php xfn_check('seo', 'nofollow'); ?> />
    <?php _e('nofollow') ?></label>
    </td>
    </tr>
  8. Save the file.

Now, when you go into the admin section and go to Blogroll / Add Link, you’ll now find a neat little checkbox that looks like this:


wordpress-seo-gray-hack.png

All you need to do is to click on the “nofollow” checkbox when adding or editing your Blogroll links and your links will then become nofollowed!

Caveats:
The hack works on my system just fine – if it doesn’t work on yours, then check the instructions again and make sure you are reading them properly.

Knowledge Constructs accepts no responsibility for any data loss, corruption to your website, loss of libido or permanent mental or physical damage cause by trying out this hack.

In the words of Spiderman’s uncle: “With great power comes great responsibility” – use the hack wisely otherwise Karma might come back and bite you in the ass.

Finally, updating your WordPress site will *KILL* this hack as WP will overwrite the edit-link-form.php file. We are working on a solution to this and may well build an SEO friendly blogroll plugin. If there’s enough interest, that is… ;)