Created
March 20, 2012 17:53
-
-
Save joshuadavidnelson/2138674 to your computer and use it in GitHub Desktop.
Displays information from an RSS Feed.
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 | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment