Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.