Feedgator RSS Aggregator

A RSS feed aggregator in php.

<?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
}
?>
view raw feedgator.php hosted with ❤ by GitHub

Source: https://gist.github.com/joshuadavidnelson/2138674

Tags: