Created
June 8, 2013 20:48
-
-
Save adapicom/5736531 to your computer and use it in GitHub Desktop.
Get an RSS Feed inside Wordpress Theme
This file contains hidden or 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
<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