Home / rss / Fetch and display RSS
  • How to Fetch and display RSS

    fetch-and-display-rss

    This script will fetch an RSS feed and display it within your wordpress theme. Make sure you change the feed URL highlighted on line 4.

    ( click code to copy )

    wordpress snippet : PHP

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

    ( WordPress codex functions, hooks, in this snippet. )

    get_permalink, fetch_feed, _e, _ex, wp,
  • Pingback: Display an RSS Feed in Your WordPress Theme | ChurchMag()

  • Jack

    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