Created
May 31, 2012 23:48
-
-
Save mintindeed/2847279 to your computer and use it in GitHub Desktop.
WordPress fetch_feed() usage example for non-post feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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