Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display RSS feeds on your WordPress site
include_once(ABSPATH . WPINC . '/rss.php');
// Feed URL
$feed = 'http://example.com/feed/';
$rss = fetch_feed($feed);
if (!is_wp_error( $rss ) ) :
// Number of maximum items to get
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
if ($rss_items):
echo "<ul>\n";
foreach ( $rss_items as $item ) :
echo '<li>';
echo '<a href="' . $item->get_permalink() . '">' . $item->get_title() . "</a>\n";
echo '<p>' . $item->get_description() . "</li>\n";
endforeach;
echo "</ul>\n";
endif;
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment