X

Fetch and display RSS


Code Snippet:


<?php if(function_exists('fetch_feed')) {

include_once(ABSPATH.WPINC.'/feed.php');
$feed = fetch_feed('http://feeds.feedburner.com/catswhoblog');

$limit = $feed->get_item_quantity(7); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items

}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>

<div>
<a href="<?php echo $item->get_permalink(); ?>"
title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
<?php echo $item->get_title(); ?>
</a>
</div>
<div>
<?php echo substr($item->get_description(), 0, 200); ?>
<span>[…]</span>
</div>

<?php endforeach; ?>

Comments  Leave a Reply

  1. every time i saw this or similar pages from searching google. no one explained step by step on how to install this. Would be nice if someone would stop expecting everyone to know this and give directions

  2. Display an RSS Feed in Your WordPress Theme | ChurchMag September 9, 2011 at 9:41 am

    […] from your other blog.Drop a RSS news feed in your theme.What other uses would be awesome?[via WordPress Code Snippets] About Eric Dye: I believe in media that matters. I have produced radio for over 15 years, […]

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 privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!