RSS Feed

Wordpress built in RSS parser

August 12, 2009 by admin 1 Comment »

A nice wordpress tip. IF you want to add RSS you can do so by just using the built in rss parser.
See the code below. Just add your rss url in the wp_rss function your done.

However this is outdated! See below for a better way to do this.

Old Way: (This may cause invalid characters when using UTF 8 encoding.)
[sourcecode language='php']
wp_rss('http://rss-feed-url', 10); ?>
[/sourcecode]

And Now for a better Way:
[sourcecode language='php']

include_once(ABSPATH . WPINC . '/feed.php');

// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://example.com/rss/feed/goes/here');

// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);

// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
?>

[/sourcecode]

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
 

One Response to “Wordpress built in RSS parser”

  1. admin says:

    test comment

    Like or Dislike: Thumb up 0 Thumb down 0

Leave a Reply

CommentLuv Enabled