getButterfly Logo getButterfly

First of all you need the Simplepie library. You only need the file included in the archive.

My example extracts 5 items from a recipe blog:

<div class=”block”>
<h2>Latest Culinary Recipes</h2>
<div class=”content”>
<?php $feed = new SimplePie(‘’);?>
<?php foreach ($feed->get_items(0, 5) as $item): ?>
<li>&raquo; <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:


Subscribe to getButterfly Blog

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.

Leave a Reply

Your email address will not be published. Required fields are marked *