Fetch and display RSS feeds


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php if(function_exists('fetch_feed')) {
  2.  
  3. include_once(ABSPATH.WPINC.'/feed.php');
  4. $feed = fetch_feed('http://feeds.feedburner.com/catswhoblog');
  5.  
  6. $limit = $feed->get_item_quantity(7); // specify number of items
  7. $items = $feed->get_items(0, $limit); // create an array of items
  8.  
  9. }
  10. if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
  11. else foreach ($items as $item) : ?>
  12.  
  13. <div>
  14. <a href="<?php echo $item->get_permalink(); ?>"
  15. title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
  16. <?php echo $item->get_title(); ?>
  17. </a>
  18. </div>
  19. <div>
  20. <?php echo substr($item->get_description(), 0, 200); ?>
  21. <span>[...]</span>
  22. </div>
  23.  
  24. <?php endforeach; ?>

URL: http://www.wprecipes.com/wordpress-tip-fetch-and-display-rss-feeds

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.