How to Modify a WordPress RSS Feed Widget with Rel=Nofollow

I just added an RSS feed widget to my site (see the lower right corner – the DZone links). I frequent dZone a decent amount, and I find a lot of the articles interesting.

However, after some thought I became concerned that ten sitewide external links might be a bit of a drain on my pagerank. If only I could add “rel=nofollow” to all those links. But there’s no option in the RSS Widget to do that.

Well, I decided to dive in and fix it myself.

Where the RSS Feed Widget is Located

This is actually a very simple hack to the WordPress source files. You’ll need to edit two lines of the file, upload it, and you should be good to go.

The file we’re looking for is “widgets.php” – it should be located in the wp-includes folder. This holds all the functions related to creating widgets and it also holds the standard widgets available in the Dashboard.

We need to scroll down, find the “RSS Feed Widget,” find where the links are created, and add “rel=’nofollow’” to those anchor tags.

Hack It Up – Add Some Code

The function we’re looking for should be around line 935 – titled “wp_widget_rss.” Once you’ve found the function, look for this line – it should be around 965.

$title = "<a class='rsswidget' href='$url' title='" . 
  attribute_escape(__('Syndicate this content')) ."'><img 
  style='background:orange;color:white;border:none;' 
  width='14' height='14' src='$icon' alt='RSS' /></a> 
  <a class='rsswidget' href='$link' title='$desc'>$title</a>";

This creates the “RSS Icon” link to the original feed. There’s a second link in there that makes the link for the title of the RSS feed. To make these nofollow, simply add the phrase rel='nofollow' right after the <a. Be sure to use single quotes around the nofollow – or else you’ll break the PHP statement and cause an error.

When complete, it should look like this. Notice that we’re adding rel=’nofollow’ in two places.

$title = "<a rel='nofollow' class='rsswidget' href='$url' title='" . 
  attribute_escape(__('Syndicate this content')) ."'><img 
  style='background:orange;color:white;border:none;' 
  width='14' height='14' src='$icon' alt='RSS' /></a> 
  <a rel='nofollow' class='rsswidget' href='$link' title='$desc'>$title</a>";

Now scroll down a bit more to roughly line 990. The line we’re looking for creates the individual links to the articles. You should see this bit of code.

echo "<li><a class='rsswidget' href='$link'
  title='$desc'>$title</a>$summary</li>";

Again, add rel='nofollow' right after the <a. The result should look like this.

echo "<li><a rel='nofollow' class='rsswidget' href='$link'
  title='$desc'>$title</a>$summary</li>";
Upload the File

That’s it. Those two small changes should make your RSS Widgets nofollow from now on – preserving your pagerank.

Simply upload the file to the server (be sure to replace the old wp-includes/widgets.php) and reload your site.

If you run into an error, double check that you used single quotes around the ‘nofollow.’ The PHP string is started with a double quote (“), so if you place a double-quote there you’ll prematurely end the string – and cause a parse error.

Bookmark and Share:
  • Digg
  • Furl
  • del.icio.us
  • StumbleUpon
  • MisterWong
  • DZone
  • Technorati

Tags: , , , ,

15 Comments to “How to Modify a WordPress RSS Feed Widget with Rel=Nofollow”

  1. Syndicate RSS Feeds on your Website for Extra Content said this on

    [...] can read this guide to find out how to hack the WordPress source to make the RSS Widget nofollow. You’ll need to know a bit of PHP, but it’s not too [...]

  2. Harry Brown said this on

    RSS Feeds are really very helpful and you could get site and news updates from it.’;:

  3. Syndicate RSS Feeds on your Website for Extra Content | Search Engine Optimization - Dtriplers Internet Marketing Solutions said this on

    [...] read this guide to find out h&#959w to hack the WordPress source to make &…. Y&#959&#965′ll need to know a [...]

  4. Articles.vp.ly » Syndicate RSS Feeds on your Website for Extra Content said this on

    [...] can read this guide to find out how to hack the WordPress source to make the RSS Widget nofollow. You’ll need to know a bit of PHP, but it’s not too [...]

  5. Angelina Ramirez said this on

    RSS feeds are really great because you are always updated with the latest news or blog posts.~`*

  6. Inflatable Bed  said this on

    i use RSS Feeds to syndicate my blog on other blogs-”.

  7. pay per call advertising said this on

    Hi, You obviously are someone who recognizes the electrical power of target and the way for making plans that you realize stage by stage.Bravo to you.In my personal lifestyle I’ve only witnessed good results when I’ve kept my aim and manufactured the measures wanted to achieve my ambitions – really minor happens by modify alone. This is a thing I like to frequently share with my readers.Truly, I’m delighted to study about other peoples success by means of laser like emphasis and you’ve got it.Continued good results for you,David

  8. L-Tyrosine Dosage : said this on

    RSS feeds are necessary for transmitting your blog updates to your readers or followers;.,

  9. two file upload java said this on

    Top-quality highlights pertaining to upload files for getting myself get going. I am going to keep this particular website link and get back to it.

  10. Buck Teeth said this on

    i think that RSS FEEDS should also be included on the list of the best inventions because it makes life easier for bloggers like us ;-’

  11. Olinda Coughenour said this on

    I’ve been browsing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.

  12. Syndicate RSS Feeds on your Website for Extra Content said this on

    [...] a tutorial on how to hack the WordPress source to make the RSS Widget nofollow. You’ll need to know a bit of PHP, but it’s not too [...]

  13. Ivey Quent said this on

    Howdy! I could have sworn I’ve been to this site before but after checking through some of the post I realized it’s new to me. Anyways, I’m definitely delighted I found it and I’ll be book-marking and checking back frequently!

  14. kingsoft pc doctor said this on

    http://www.ccleaner.com – looks like the guy above beat me to it!

  15. sanibel island resorts said this on

    Hey there, I need to ask you one thing. Is this a wordpress web site? I am planning on shifting my weblog from Blogger to wordpress, do you think that is achievable? Additionally did you set up the following theme yourself some how? Many thanks for your assistance!

Leave a Reply