Google it! / Yahoo it! / Bing it! / Ask it!

RSS

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:

<div class="block">
	<h2>Latest Culinary Recipes</h2>
	<div class="content">
		<?php $feed = new SimplePie('http://www.wordpress-site.com/feed');?>
		<ul>
			<?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; ?>
		</ul>
	</div>
</div>

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:

include('includes/simplepie.inc');

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>