Skip to content

Instantly share code, notes, and snippets.

@alexroan
Created July 6, 2019 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexroan/3a983a4720ba645e8015a270e45ad68d to your computer and use it in GitHub Desktop.
Save alexroan/3a983a4720ba645e8015a270e45ad68d to your computer and use it in GitHub Desktop.
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH.WPINC.'/feed.php');
$feed = fetch_feed('https://www.snippet.uk/groups/not-forgotten/blog/feed/all');
$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 feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>
<div>
<a href="<?php echo $item->get_permalink(); ?>"
title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
<?php echo $item->get_title(); ?>
</a>
</div>
<div>
<?php echo substr($item->get_description(), 0, 200); ?>
<span>[...]</span>
</div>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment