Skip to content

Instantly share code, notes, and snippets.

@jq-87
Created December 2, 2013 16:33
Show Gist options
  • Save jq-87/7752260 to your computer and use it in GitHub Desktop.
Save jq-87/7752260 to your computer and use it in GitHub Desktop.
//source: http://www.dangayle.com/import-feeds-wordpress-fetch-feed/
function custom_rss($feedUrl = 'http://wordpress.org/news/feed/'){
include_once(ABSPATH . WPINC . '/rss.php');
$feed = $feedUrl;
$rss = fetch_feed($feed);
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
if ($rss_items):
echo "<ul class='custom-rss'>\n";
foreach ( $rss_items as $item ) :
printf('<li><a href="%s">%s</a><p>%s</p></li>',$item->get_permalink(),$item->get_title(),$item->get_description() );
endforeach;
echo "</ul>\n";
endif;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment