Inspiration For Creative Minds
Home » Labs » Fetch and display RSS in WordPress  

Filed under Labs

Copy and paste below code in your WordPress template then the code will display the title and description of most recent feed item according to the number which set in variable ‘$items’.

 
<?php
include_once(ABSPATH.WPINC.'/rss.php'); // path for including include
$feed = fetch_rss('http://mydoamin.com/feed/'); // specify your feed url
$items = array_slice($feed->items, 0, 20); // specify the numbers of items to display
?>
 
<?php if (!empty($items)) : ?>
<?php foreach ($items as $item) : ?>
 
<h3><a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></h3>
<p><?php echo $item['description']; ?></p>
 
<?php endforeach; ?>
<?php endif; ?>
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook
Labs

Posts you may like: