I don’t remember where I got this code example but this is really useful to pull some external RSS feed into your WordPress site. You can paste the following code in any of you WordPress theme file and change a few options.
Here is the code:
// Get RSS Feed(s)
include_once(ABSPATH . WPINC . ‘/feed.php’);
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed(‘http://feedurl.com/’);
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(3);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo ‘<li>Aucune Nouvelles.</li>’;
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>’>
<?php echo $item->get_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
This is will basically pull a list of the later feed from the address specified above
Leave Your Response