Skip to content

Instantly share code, notes, and snippets.

@onestepcreative
Created June 9, 2012 04:30
Show Gist options
  • Select an option

  • Save onestepcreative/2899477 to your computer and use it in GitHub Desktop.

Select an option

Save onestepcreative/2899477 to your computer and use it in GitHub Desktop.
// RSS Dashboard Widget
function freshDashboardRSS() {
if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php'); // include the required file
$feed = fetch_feed('http://blog.onestepcreative.com/feed/rss/'); // specify the source feed
$limit = $feed->get_item_quantity(7); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo '<div>The RSS Feed is either empty or unavailable.</div>'; // fallback message
else foreach ($items as $item) : ?>
<h4 style="margin-bottom: 0;">
<a href="<?php echo $item->get_permalink(); ?>" title="<?php echo $item->get_date('j F Y @ g:i a'); ?>" target="_blank">
<?php echo $item->get_title(); ?>
</a>
</h4>
<p style="margin-top: 0.5em;">
<?php echo substr($item->get_description(), 0, 200); ?>
</p>
<?php endforeach;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment