home

MY BLOG BYTES

WordPress built in RSS parser

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]

No TweetBacks yet. (Be the first to Tweet this post)
This entry was posted in feature, wordpress. Bookmark the permalink.

One Response to WordPress built in RSS parser

  1. admin says:

    test comment

    Like or Dislike: Thumb up 0 Thumb down 0

blog comments powered by Disqus