How to Make RSS Widget Links NoFollow in WordPress 3.0
Adding an RSS feed your sidebar from a respected site that updates articles frequently is a good way to add dynamic content and keep your WordPress blog fresh even when you don’t have the time to add new content. You see on the right sidebar of this site there is a section called “Web News” which does exactly that. This is accomplished by adding the default RSS widget to the sidebar in WordPress admin and putting the feed URL in the feed field.
Easy enough, but you may not want to let your PageRank juice leak off your home page to this site. Having a link that takes people off-site is enough trade-off for the right to use their content. You don’t need to give them your PR too!
*NOTE the following How-To is for webmasters who have full admin rights to their blog and have access to the source pages to edit. Those with Worpress.com blogs, this does not apply. If you attempt this please backup any edited file first in case you hose your blog. Some basic php editing knowledge is recommended.
The only file that will be modified is wp-includes/default-widgets.php
To make these links “nofollow’ and thus saving your link PR juice, you need to do the following:
1. Located and open for editing “default-widgets.php” in the “wp-includes” folder of your WordPress installation. (this is for WordPress 3.0, older versions had the code in “widgets.php” in the “wp-includes folder”.)
2. Around line 740 you will find the following code:
$title = "<a class='rsswidget' href='$url'
title='" . esc_attr__( 'Syndicate this content' ) ."'><img style='border:0'
width='14' height='14' src='$icon' alt='RSS' /></a> <a
class='rsswidget' href='$link' title='$desc'>$title</a>";
- Replace with the following:
$title = "<a class='rsswidget' href='$url'
rel='nofollow' title='" . esc_attr__( 'Syndicate this content' ) ."'>
<img style='border:0' width='14' height='14' src='$icon'
alt='RSS' /></a> <a class='rsswidget' href='$link' rel='nofollow'
title='$desc'>$title</a>";
The ‘nofollow’ attribute is added in two places as highlighted in green.
3. Find the next bit of code around line 862. Replace the following:
echo "<li><a class='rsswidget' href='$link' title='$desc'>
$title</a>{$date}{$summary}{$author}</li>";
– Change to:
echo "<li><a class='rsswidget' href='$link' rel='nofollow' title='$desc'>
$title</a>{$date}{$summary}{$author}</li>";
Again the highlighted ‘nofollow’ attribute is added.
4. Save and upload to your server.
5. Open up your blog website and test.
I recommend using a Firefox addon called “NoDoFollow” – which is turned on or off in the right-click context menu and will show regular (dofollow) links and nofollow links using color coded backgrounds. This way you can see ALL the links on a page and identify them for their ‘follow’ attribute.
Happy blogging!
Comments
Comment from gia
Time January 25, 2011 at 8:18 am
wow.very thanks,it’s working
Comment from Peter
Time April 21, 2011 at 12:21 pm
yes it’s working..thanks man:)
Comment from robert
Time October 26, 2010 at 12:29 pm
thanks for this , used it today and it works a treat