How to: Display any rss feed on your WordPress blog

Do you ever wanted to be able to display any rss feed on your WordPress blog? If yes, here’s a simple code that will get that thing done. Do you know that WordPress have a function, called wp_rss(), which is nothing else than a built-in rss reader?

Here's the simple code to add where you want the rss to be displayed (Personally, I'd use my sidebar, my footer or a page template):

<?php include_once(ABSPATH . WPINC . '/rss.php');
wp_rss('http://feeds.feedburner.com/wprecipes', 3); ?>

Let's have a quick look to the code: First, we're including the rss.php file, which is a part of WordPress core. This file allows us to use the wp_rss() function.
This function takes two parameters: The first is the rss feed url, and the second is the number of rss entries to be displayed.

81 Responses

Oct 18 2008 13:45

This is probably how spam blogs are created, right? Theses suckers who steals your content…

Oct 18 2008 13:50

Exactly, at least most of it.

Oct 18 2008 16:56

Great!

Oct 19 2008 15:21

Great! This is something that I’ve been looking for. I need to parse the feed from my blog to another. So is as simple as putting the php function on the sidebar, right?

Yan

Oct 19 2008 15:33

Exactly, this piece of code can parse any feed, anywhere :)

Oct 20 2008 09:30

This is quite useful as it takes an item that could previously not have been put on a site and makes it place-able. The description of the code parts is a nice touch.

Oct 22 2008 14:38

simple way to make a planet site, right?

Oct 24 2008 16:28

I run a small (40-50) annual blogger event, and last year readers were having some trouble keeping track of all of the coverage on the blogs. I would like to have the RSS feeds from the various sites feed onto the main site during the event.

We had a smaller event of about 10 people during the summer in which I tried a plugin that would supposedly republish a feed. It did, but it ate up so many resources that my hosting company complained, and it wasn’t reliably checking the feeds to boot. I had to manually tell it to check probably 80% of the time.

I could see how I could use this hack, but I would (presumably) have to break up each and every blog on the page. I’d ideally like to have it flow as different people post on their own pages, it submits the posts to the event site. (Ex. Blog A posts at 7:55, Blog B posts at 8:16, Blog C at 8:50, Blog A again at 9:00, and the posts show up as A, C, B, A, all the blogs mixed together.)

Does anyone know a good way to do that? If not, I’ll keep looking for solutions, but even this would be a bit of a lifesaver and much easier to handle.

Oct 24 2008 23:52

@Bitter: This is possible, but it seems to be a quite big development. Did you checked out if there’s a WP plugin to do that?

Oct 25 2008 00:33

WP-o-Matic claims that it does this, but it was the plugin I mentioned that ate up so many server resources and didn’t really do what it was supposed to do. I had to manually tell it to check feeds 80% of the time.

Like I said, I could get away with using it again since I only need it to run for about 4 days. But if there’s something that would mean I could actually focus on doing my own updates, let me have time to get video edited from the weekend, and wouldn’t get me yelled at by my hosting service, I would happy. :)

Oct 25 2008 04:39

Hey Jean

Off-topic, do you have any idea how to limit the # of characters on post excerpt without plugin?

Yan

Oct 25 2008 07:13

@Yan: I think a filter can do that…I’ll do some research and I’ll tell you more about it :)

Nov 12 2008 11:08

Great code ! But accents raise problem when I import facebook RSS feed: “Démian se souvient des jours anciens”. Do you know how to resolve this ? Many thanks in advance.

Nov 12 2008 12:51

@Bitter, you can use SimplePie for that (http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress/start). It’s an RSS parser packed into a plugin which will allow you to fetch feeds from different sources, sort them and display them as you wish.

Nov 12 2008 15:29

Oh, thank you! I’ll check that out.

Nov 12 2008 17:18

Just ask for help if you find trouble, I have used it many times myself. Good luck!

Nov 14 2008 10:44

@Démian: This should help you :)

Nov 14 2008 21:49

Thanks jbj, but this solution does’nt work. Is there a special configuration to be made in Feedburner ?

Nov 15 2008 00:03

@Démian: Sorry to hear that. Sadly, I never had this problem so I don’t know how to help you more :(

Nov 28 2008 10:58

I was looking for that, many thanks.
As Bitter, WP o Matic don’t work as I would :)

Dec 03 2008 09:14

Cheers for this. Was wondering how it was done!

Dec 07 2008 11:46

Awesomne piece of recipe, keep the codes cooking for more :) I was just able to help myself out and someone in the Support Forums.
Just one question, how can I show excerpts of those blogs I try to display the feeds?

Dec 07 2008 12:25

@Kevin Paquet: No, sadly you can’t only get an excerpt.

Dec 10 2008 04:02

Why does a simple php include of the rss feed break down my WP site, but this code works? I’ve been looking online allover for something like this so that is great.

Also, why does this cap out at 10 entries?

Jan 06 2009 11:27

Hey Jean

I tried to add the code into Thesis ‘text’ widget but for some weird reasons, it appears none.

Here’s where it’s supposed to be
http://sponsoreview.com/

Yan

Jan 06 2009 13:47

@Yan: I don’t think it works in text widgets, sadly.

Jan 17 2009 15:40
Jan 27 2009 21:07

Anyone know of a parameter that can be added to display the content of the feed in addition to just the title?

Feb 26 2009 08:00

I have been looking ALL over for this! thank you so much!!!

Mar 16 2009 05:36

Code works great!

However, is there anyway to get it to stop displaying as a list? For some reason, even if I change my CSS to list-style:none;, it still shows the bullet points.

Thanks!

Apr 10 2009 01:50

thx alot

May 04 2009 19:47

Great blog. I’m just beginning to get familiar with Wordpress and there are a lot of little things I need to do to my blog.

I’ve added your blog to my blogroll so I ran refer to it often.

May 05 2009 21:17

Hi people! first of all, sorry my english, i speak spanish, but i will do the best effort to understand me, I have long time sought a way to show products of other sites in my wordpress blog, via feeds, i found many ways of do this, and the way of this post is one, but none has been useful, what i want, is something to show diferent products, like shoes for example, and order by categories, like casual shoes, sport shoes, tennis shoes, etc, and in each category show the diferents products with 1 picture, name, little description and a link of course, but no matter what the product site, for example under casual shoes i can show 1 adidas shoe by adidas.com, and 1 converse shoe, by converse.com, all of this via xml, i found a product and change for i want, but doesn’t match at 100%, and does not function with wordpress, little problem :P , what i want would be something like shopzilla.com, but free, i want to create different sites of diferents things i like, for example a site who talk about cars, and i give the info to my visitors of see the same car of different sites in 1 only page, i know this is dificult to do, but is any of you can help me out whit this, i really appreciate!!! and of course make a huge post with the solution for some one else, thank you very much! and i wait for your response

May 06 2009 14:42

A very useful tip, thanks.

May 11 2009 22:54

Can this code snipet be used in a WordPress POST? I’ve tried to insert the code as above inside the body of an existing blog post but, sigh, it doesn’t like commands.

Any thoughts of how to include RSS feed data within the post itself, not a template???

May 14 2009 00:40

When i use this code, the page just breaks at that point (stops rendering anything after). Can this be used on any template or included page? Are there other global settings that are required? thanks!

May 14 2009 14:06

I’ve since discovered on my own that you need a plugin {exec-php} that allows php code to be executed on POSTs. That seems to do the trick.

Doesn’t work without it.

Jun 10 2009 19:15

Very useful and thanks. I ran into one snag though. I often get this error, though not all the time when I try to add another feed:

Warning: array_slice() [function.array-slice]: The first argument should be an array in /home/manrilla/public_html/blog/wp-includes/rss.php on line 890

Sometimes I get it – sometimes I don’t. Very odd. Any thoughts as to why this is happening?

Jun 12 2009 13:04

@marc

I think u got to check u r feed url that u r putting into the

function…

wrong feed url generally gives this sort of error if it still not solves ur problem u

can try using fetch_rss function instead of this

http://codex.wordpress.org/Function_Reference/fetch_rss

cheers…..

Jun 12 2009 14:19

@shashank,

Thanks. I tried using the fetch_rss function instead and it seems to work. Not sure why the other one would work and then not work [using the same url for the feed].

Much appreciated!

Jun 12 2009 17:06

@marc

good to hear that ur problem is solved now

am a wordpress theme designer n plugin developer in case u need

further assistance regarding what so ever feel free to contact me at

shashank.mishra.cs AT gmail.com

Jun 12 2009 22:23

I will certainly keep you in mind! I still am seeing that issue crop up from time to time where it says:

Warning: array_slice() [function.array-slice]: The first argument should be an array in /home/manrilla/public_html/blog/wp-content/themes/bresciani/sidebar.php on line 31

* No items

I am not sure what that means. I haven’t changed anything it’s just that sometimes it seems to work and other times no.

Jul 01 2009 23:28

great advice. this plugin might be useful also but i have not tried it yet
http://wordpress.org/extend/plugins/super-rss-reader/

Aug 19 2009 16:08

Thanks so much!! This worked like a champ. I wanted to put a few headlines from my blog at my business site – took me less than 2 minutes!

Sep 24 2009 00:57

Great tip! Is there a way to open the links in a new window?

I’ve tried target=”_blank” but can’t get it to work.

Thanks!

Sep 25 2009 14:24

wp_rss function cannot be use to call other rss in the same page. i used the function to call two feeds but, one is showing nicely and other there is error. Need Help

Oct 29 2009 21:02

thanks,

it works

Nov 06 2009 00:51

How do you include more than one feed in the code?

Nov 07 2009 07:50

What will be the exact code if I want to input the feed link from the post custom field and giving a default number of feeds to show.

Dec 19 2009 17:06

wp_rss function shows only title, right?
i want to display the details in feed information but dont know how to do,

Jan 17 2010 00:37

Are you available for a quick RSS question? I am trying to get news feeds to post automatically in my home page under specific category. The site I am working on is SBCTeaParty{dot}com. I want the feed to appear under “conservative news”. I am using Feedwordpress and that works, however, it won’t import images. I want the images too and am tired of beating my head against the computer screen. If you look at redlandsteaparty{dot}com/rpress/ you can see there news feeds right onto the home page and includes videos and images along with some posts. Can you please help. :)

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required