Home | Contact | Videos | MediaZo

How to show RSS feeds in a WordPress Page and Posts

Most of the bloggers having different blogs (on same or other domain) wants to aggregate the updates on the same page. If you wants to show different blogs latest post links on a wordpress page then its very easy to show rss feeds within wordpress with the help of simplexml. The following codes displays the feeds from the single feed url.
How to show rss feeds in wordrpress pages How to show RSS feeds in a Wordpress Page and Posts

<?php
$xml_file = 'http://feeds.feedburner.com/honeytechblog';
$xml = simplexml_load_file($xml_file);
$xml_channel = $xml->channel->item;
for ($i=0; $i<5; $i++) {
//print_r($result);
?>
<div>
<a href="<?php echo $xml_channel[$i]->link; ?>">
<?php
echo $xml_channel[$i]->title."</a></div>";
}
?>

There are some parameters which can customize your requirements like:

  • $xml_file = Feed Url for example i use
    $xml_file = 'http://feeds.feedburner.com/honeytechblog';
  • Value of i for no of links, for example i<5 shows 5 links of the feed

Alternate Code

(tested on various clients blogs)

<ul>
  <?php
error_reporting(0);
$url = "http://feeds.feedburner.com/micro-news";    
$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
echo $xml;
if ($xml == "")
{
 echo "Feeds are down, Try again later";
}
else
{
$blog = $xml->channel;
for($i=0; $i<3; $i++) {
?>
 <li><a href="<?php echo $blog->item[$i]->link; ?>"><?php echo $blog->item[$i]->title; ?></a> </li>
  <?php
}
}
?>
</ul>

Note

If you wants to run this php code apart from the WordPress themes i.e in wordpress posts and pages then you need plugins like Exec-PHP. Exec-PHP will executes PHP code in posts, pages and text widgets .

This post is dedicated as an answer to amitbhawani question

Is there any WordPress Plugin which shows 5 Recent Posts of any Feed in a WordPress Page? Ex :Show my news blog latest posts on about page


Honey Singh is Head of Operations & Strategic Planning at MediaZo. He has an experience of 5 years in designing, ideating/operating digital/social marketing strategies for global brands. You can also catch him on Foursquare, Twitter, Facebook , Google+ & Instagram.

16 Responses to “How to show RSS feeds in a WordPress Page and Posts”

  1. @amitbhawani to show RSS feeds in a WordPress Pages and Posts http://bit.ly/QW6Zv

  2. Did you try out this stuff on one of your post / page? Iam asking this because the code is not executing itself and i guess we need to upload some files?

  3. @Amit
    I already tested the above codes on various blogs.
    There is no need to upload any external files in wordpress engine because it already had the simplexml parsers.
    I also implement a working examples in this post.

    The code may not be executing because its a php and you haven’t yet install the Exec-PHP
    http://wordpress.org/extend/plugins/exec-php/

  4. @amitbhawani No need to upload any external files in #wordpress, already had the simplexml parsers. Rest comments >> http://bit.ly/QW6Zv

  5. Good to see that you wrote a detailed post to help one of your reader.

    Appreciate it :-)

    @djain1989
    .-= Deepak Jain´s last blog ..Bolt Browser comes out of Beta, gets Better! =-.

  6. Thanks this is working, will post a tweet when the site is up with all the feeds stuff :)
    .-= Amit Bhawani´s last blog ..WordPress Blog Backup Plugins Tools & Tutorials =-.

  7. Yours Welcome Amit !
    There is lot more customizations possible with xml feeds. For example we can auto fetch the images, thumbs and etc.
    Working examples are at the home page of http://www.honeytechblog.com/

  8. I’ve been looking for something like this to implement on WP blogs.

    Thanks for posting this code!
    .-= Bryan – After5PC´s last blog ..Why Outsource? When Hiring a Web Designer or Programmer is Good For You =-.

  9. RSS Feeds are really very helpful and you could get site and news updates from it.–,

  10. Feedburner is really very useful for syndicating feeds from other websites.*`-

  11. RSS feeds plays an important role for a website and you made it very clear with the step by step installation procedure. Well done.

  12. I’d search tried and delete several options. Till I found this one. works (almost) instantly!

    TX!!

  13. i always use feedburner to syndicate my blog posts to other subscribers.’*:

  14. i always use feedburner to syndicate my blog posts to other subscribers.–`

  15. Hi there,
    Thanks for the tut! It works brilliantly. I wanted to know if you could guide me on:

    a) How can I make the list bulleted?

    b) How can I auto fetch images/thumbnails with xml feed?

    Appreciate your guidance.

  16. Hi thanks for posting this good information.
    I really need to add rss feeds in my websites using wordpress.
    Thanks a lot.
    Please provide more useful tips like this

Leave a Reply


+ seven = thirteen