• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Using SimplePie to get an RSS Feed
 

Using SimplePie to get an RSS Feed

on

  • 372 views

Using the SimplePie object to get, parse &output an RSS feed in WordPress

Using the SimplePie object to get, parse &output an RSS feed in WordPress

Statistics

Views

Total Views
372
Views on SlideShare
372
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Using SimplePie to get an RSS Feed Using SimplePie to get an RSS Feed Presentation Transcript

    • http://simplepie.org/Allows you to get and manipulate RSSfeeds in a simple and standard way
    • Use the fetch_feed() function to get an RSS feed<?php $feed = fetch_feed( $uri ); ?>http://codex.wordpress.org/Function_Reference/fetch_feedReturns a SimplePie object.Built in API so you don’t have to use the SimplePie site.
    • <div class="latestnews"><a href="<?php echo home_url( / ); ?>/“ title="HLS Services Blog"><h2>Latest News</h2></a><ul><?php if(function_exists(fetch_feed)) {include_once(ABSPATH . WPINC . /feed.php); // the file to rss feed generator$feed = fetch_feed(http://feeds.feedburner.com/myfeedname); // specify the rss feed$limit = $feed->get_item_quantity(5); // 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) : ?><li><div class="latestnews_textwrap"><h4><a href="<?php echo $item->get_permalink(); ?>" alt="<?php echo $item->get_title(); ?>"><?php echo $item->get_title();?></a></h4><p class="date_posted"><?php echo $item->get_date(l, F j, Y); ?></p></div></li><?php endforeach; ?></ul></div><!-- .latestnews -->
    • All classes and methods are documented on theSimplePie website athttp://simplepie.org/api/class-SimplePie.html