First of all you need the Simplepie library. You only need the simplepie.inc file included in the archive.
My example extracts 5 items from a recipe blog:
<h2>Latest Culinary Recipes</h2>
<?php $feed = new SimplePie(‘http://www.wordpress-site.com/feed’);?>
<?php foreach ($feed->get_items(0, 5) as $item): ?>
<li>» <a href=”<?php print $item->get_permalink();?>”><?php print substr(($item->get_title()),0,23);?> […]</a></li>
<?php endforeach; ?>
I have also included a
substr() function to show only the first 23 characters in the title. It fitted my web site better.
Don’t forget to have the simplepie library included at the top:
Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.
If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.