Categories: Tips & Tricks

How to: Display RSS feeds from anywhere

Here is a simple way to display any RSS feed in your WordPress blog.

<?php include_once(ABSPATH . WPINC . '/rss.php');
 $rss = fetch_rss('http://feeds2.feedburner.com/WPCult');
 $items = array_slice($rss->items, 0, 4);

  if (empty($items)) echo '<li>No items</li>';
  else
   foreach ( $items as $item ) : ?>
            <a style="font-size: 14px;" href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a><br /> 
            <p style="font-size: 10px; color: #aaa;"><?php echo date('F, j Y',strtotime($item['pubdate'])); ?></p>
            <p><?php echo substr($item['summary'],0,strpos($item['summary'], "This is a post from")); ?></p>
            <?php endforeach; ?>

The first step is to include the WordPress file rss.php then will apply code after to style the feeds.

Of coarse I forgot to mention, change the RSS feed to the feed you want to pull.

Web Master

Hi, I am Miguel, I bought this site in 2009. So I now run or manage the site. Please visit my new website or follow me on twitter @W3i.

View Comments

  • Wow, actually I want to ask you how to do that...but, you already answer it with this post :)
    anyway, I've question for you, please look at your mailbox and answer it ASAP..thx very much...

  • Very cool - I had no idea this functionality was built in. I see quite a few projects where people want this type of thing built, and I had assumed you'd have to build your own parser.

    Does anybody know how long Magpie has been in wordpress? This could have saved me lots of time..

  • Thanks but I need some more direction The code you have listed- where do I put that? In the post or page? Appreciate your time

Recent Posts

21 Effective Strategies to Amplify Website Traffic

The article provides a comprehensive guide to driving traffic to your website, highlighting 21 effective…

9 hours ago

Essentials for Ecommerce Website Development

While e-commerce is projected to account for more than $6.5 trillion in sales by 2023,…

21 hours ago

17 Essential Link Building Statistics and Trends for Enhanced SEO

The analysis highlights the significance of link-building in SEO, revealing that most websites neglect backlinks,…

1 day ago

Get a copy of the book Blog Blazers!

Hey everyone, I've got two copies of Blog Blazers that I want to give away…

2 days ago

101 of the best blogging tools in 2024,

101 of the best blogging tools in 2024. Having the best blogging tools continues to…

2 days ago

Remove the title attribute using jQuery

In WordPress, when you use wp_page_menu your anchor attribute's usually carry a title with the…

3 days ago