(+84) 463.28.7979

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>