Skip to content

Instantly share code, notes, and snippets.

@ihorvorotnov
Created February 21, 2014 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihorvorotnov/9132705 to your computer and use it in GitHub Desktop.
Save ihorvorotnov/9132705 to your computer and use it in GitHub Desktop.
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