A RSS feed aggregator in php.
This file contains 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
<?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 | |
} | |
?> |
Source: https://gist.github.com/joshuadavidnelson/2138674
Tags: RSS