Fetch and display RSS in WordPress

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; ?>

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …


Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us