Skip to content

Instantly share code, notes, and snippets.

@mintindeed
Created May 31, 2012 23:48
Show Gist options
  • Save mintindeed/2847279 to your computer and use it in GitHub Desktop.
Save mintindeed/2847279 to your computer and use it in GitHub Desktop.
WordPress fetch_feed() usage example for non-post feeds
$rss = fetch_feed('http://example.com/feed/');
if ( ! $rss ) {
return;
}
$maxitems = $rss->get_item_quantity();
if ( ! $maxitems ) {
return;
}
$rss_items = $rss->get_items(0, $maxitems);
if ( ! $rss_items ) {
return;
}
foreach ( $rss_items as $item ) {
$element_name = 'example';
$data = $item->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, $element_name);
if ( isset($data[0]['data']) ) {
var_dump($element_name . ' is ' . $data[0]['data'] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment