Have you ever wanted to add an external RSS feed to your WordPress blog?  This is a great way to promote one of your other blogs (if it is in a similar niche) on a more popular site you run.

Most of you will probably remember that about a month ago we finally got around to launching our WordPress Forums, which has an RSS feed associated with it.   In order to cross-promote our forums on this site, I wanted to display our most recent forum posts in the sidebar here at WordPress Hacks.

In order to accomplish this, I grabbed the following code from Jean’s post over at Smashing Magazine:

<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://wpforums.com/external.php?type=RSS2', 5); ?>

It takes the rss.php file that is built into WordPress (used for widgets).  In this code it is set to display the most recent 5 posts from the RSS feed “http://wpforums.com/external.php?type=RSS2.”

Here is how it looks:

I have gone ahead and added this to our WordPress Code page for easy reference.

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  1. Rarst says:

    I think there is native widget for that as well?

    I use “KB Advanced RSS” plugin – for showings custom software updates feed in my sidebar. Needed something customizable to showing two different links on each item (post and download).

  2. Kyle Eslick says:

    @ Rarst – Yes, there is a widget for RSS feeds, though this gives you a little more control and can be placed anywhere (not forced to use sidebar or other widget enabled areas).

    Maybe I’m weird, but I prefer hard coding things. :D

  3. Mario Andrade says:

    I’ve tryed to use it fetching another wordpress url but it gives an error saying the feed probably doesn’t exist but it does…

  4. Deca says:

    I just discovered your blog and just finished reading it page to page. Thanks for this nice tips

  5. edzzy says:

    very informative site, i will to add another RSS on my site.. thanks for the tip. keep up the good work. ;)

  6. jackie says:

    great – just added it to my singlepost.php and page template and it works 100%

    Thanks a million :D

  7. Aaron says:

    Thanks for the tip. I assume that this piece of code will have to be added to the template file, right. My problem is that I only want the feed to show up in the body of one page (not all my pages). Any idea how I can do that?

  8. Kenneth says:

    Is it possible to change the output to show more things like text, images etc…

  9. John Weaver says:

    Your method is described more easily. I have also written a post on this topic on my blog which is called WordPress: Displaying External RSS Feeds

    But I have redirected visitors to SimplePie which is at the core of the feed fetching mechanism built in wordpress.

  10. kailoon says:

    Is it possible to get the image from the posts too ?

  11. D.Lo says:

    Great post! It looks like this particular function is deprecated in WordPress now, so the suggested method from the codex is http://codex.wordpress.org/Function_Reference/fetch_feed. Thanks so much for getting me started!

Trackbacks/Pingbacks »

  1. Spirit of Wordpress #3 ! | le blogueur masqué says:
  2. Links To Beat The Holiday Blues | This Month In SEO - 12/08 | TheVanBlog | Van SEO Design says:
  3. 20 More WordPress Code Snippets and Hacks | Wpfail.com says: