Posted by KaiseRCrazY on 5th December 2009

Fetch and display RSS feeds

JBJ (WpRecipes) was released a WordPress tip about RSS. With this tip you can display RSS feed where you want. Only paste this code where you want to show your RSS Feed. Let’s Begin.

Here is the code;

Don’t forget change rss url on line 4.

<?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; ?>

This code shows RSS Feed with 200 chars description.

Here is the original post!

  • del.icio.us
  • Digg
  • Facebook
  • FriendFeed
  • Reddit
  • StumbleUpon
  • Technorati
  • PDF
  • Print

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

    1 Response

  1. [...] This post was Twitted by wpfunc [...]

Post your comments