Free Wordpress Blog Setup

How to Display Any RSS Feed on Your WordPress Blog

By Editorial Staff in Tutorials
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

Free Wordpress Blog Setup

Comments

5 Responses to “How to Display Any RSS Feed on Your WordPress Blog”
  1. 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

  2. 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!

  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.

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting