Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Display Any RSS Feed on Your WordPress Blog

Last updated on by
BlueHost - Recommended WordPress Hosting
How to Display Any RSS Feed on Your WordPress Blog

There are times when you want to display external RSS feed on your blog. Perhaps a blog feed of your another blog or some other site. Well you do not need a plugin to do this because WordPress have a function built in that will take care of this. In this article we will show you how you can display an external RSS feed on your blog. This way you can even use WordPress as a news aggregator.

Simply paste the following code in any WordPress file that you choose. Preferrably in a custom page that you create.

<?php include_once(ABSPATH.WPINC.'/feed.php');
$rss = fetch_feed('http://feeds.feedburner.com/wpbeginner');
$maxitems = $rss->get_item_quantity(5);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php echo $item->get_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>

Make sure you change the feeds url and the quantity and any other setting that you like.

Source: WordPress Codex


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. CY says:

    Hello

    Is there any plugin or hack that I can use to display multiple RSS feeds on my WordPress site?

    For example, how do I display news excerpts from CNN, Reuters, NYT, etc?

    Possible to display specific feeds based on keywords? For example, Pinterest?

    Would be most grateful to get an answer as I have been searching high and low for the past week.

    Thanks in advance.

    • Editorial Staff says:

      You can use a plugin called FeedWordPress (We used it a while ago). People are reporting that it is broken, but you can give it a try. Alternatively, use Yahoo Pipes to combine all of your feeds. Then use the pipes feed to display it on your blog.

  2. Himanshu says:

    What alterations in the code should i do in order to fetch the feed from multiple links?

    Thanks

    • Editorial Staff says:

      Not sure if you can do that with this code alone. You would have to use something like Yahoo Pipes or another combine all the feeds into one. Then use it with this code. Alternatively, there are plugins like FeedWordPress that lets you do what you are talking about.

  3. BdF says:

    Yes but: discovering a feed depends on the server the feed emanates from. Since you will want to display several feeds from several different sites, if at some point ONE server is slow or down, the code will get stuck. This has been the weakness of many feeds plugins.

  4. Kimberly Yow says:

    I had previously been told this could only be done in a sidebar so I am happy to see your post and the necessary code. Thanks for sharing!

    • Editorial Staff says:

      Nope, any where you really want to do it. Sidebar, footer, Separate page, author page, any thing that you like.

  5. T-trix says:

    i think a screenshot will be better than no one

    • carlitos says:

      Its good to show data from other websites, if you run a sports blog you can to a custom page or your own sidebars and title it like “Espn Headlines” or “FoxSports Last News”.

      Thanks for this code wpbeginner

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.