Skip to content

Instantly share code, notes, and snippets.

@adapicom
Created June 8, 2013 20:48
Show Gist options
  • Save adapicom/5736531 to your computer and use it in GitHub Desktop.
Save adapicom/5736531 to your computer and use it in GitHub Desktop.
Get an RSS Feed inside Wordpress Theme
<ul>
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php');
$rssfeed = get_post_meta($post->ID, 'rssfeed', true);
$feed = fetch_feed($rssfeed);
$limit = $feed->get_item_quantity(10);
$items = $feed->get_items(0, $limit);
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>
<li>
<a href="<?php echo $item->get_permalink(); ?>"
title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
<?php echo $item->get_title(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment