Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Created March 20, 2012 17:53
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 joshuadavidnelson/2138674 to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/2138674 to your computer and use it in GitHub Desktop.
Displays information from an RSS Feed.
<?php
/* ------ [ "FeedGator" Rss Aggregator ] ------ */
function rss_agg($feed,$num,$desc) {
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed($feed);
if(!empty($rss)):
$maxitems = $rss->get_item_quantity($num);
$rss_items = $rss->get_items(0, $maxitems);
endif;
?>
<ul>
<?php if ($maxitems == 0) echo '<li>Nothing at the moment...</li>';
else
foreach ( $rss_items as $item ) : ?>
<li><a href="<?php echo $item->get_permalink(); ?>" rel="bookmark"><?php echo $item->get_title(); ?></a>
<p class="footnote"><?php echo $item->get_date('M j Y'); ?></p><?php ?>
<?php if($desc == 1) {
echo '<br />';
echo $item->get_description();
} elseif($desc == 0) {
echo null;
} ?></li>
<?php endforeach; ?>
</ul> <?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment