PHP DIY – How to Add RSS Feeds to Any Website/Blog using Magpie RSS Parser!

One of the most common things we do in today’s Web2.0 programming are RSS feeds.  Now there’s a bunch of ways you can add RSS feeds to your website but let me tell you the BEST way using PHP.

1) Download and unzip Magpie RSS in your website root directory somewhere.

2) Anywhere in your PHP code, add the following line, while making sure the full directory path is specified.  (I usually like to put it in directory such as “magpie”)

require('rss_fetch.inc');
$myurl="https://zedomax.com/blog/feed";
$rss = fetch_rss($myurl);
        $ct=0;
foreach ($rss->items as $item ) {
           $title = $item[title];
           $desc = $item[description];
           $url   = $item[link];
           echo '<li><a href="'.$url.'" title="'.$desc.'">'.$title.'</a></li>';
           if($ct==9) break;
           $ct++;
}

This will output the latest 10 RSS items. You can of course, change values and also do much more with more configuration.  Refer to Magpie RSS Documents here.

There, you can probably do this in 5 minutes.  I find it better to use this over any other WordPress RSS plugin because it’s simple and it works.  I used to use a plugin that kept dying on me or was simply too slow.

Using straight Magpie RSS is really fast and great for making some custom RSS sites.

Of course, couple it with PHP caching and you already got a website that can handle a LOT of traffic. 🙂

6 Responses to PHP DIY – How to Add RSS Feeds to Any Website/Blog using Magpie RSS Parser!

  1. Women's Ladies Clothes says:

    I must be dumb, I’ve always wanted to know how to do this and you and do it in 5mins!

  2. Lauren says:

    Hi. I read a few of your other posts and wanted to know if you would be interested in exchanging blogroll links?

  3. johnhoma says:

    Hello, I can’t understand how to add your blog in my rss reader.plz tell me thank you.johnhoma

  4. max says:

    You can subscribe via e-mail too, or use Google RSS reader.

  5. Gardening Shops says:

    Oi! Just what I need to know, Magpie always confused me.

  6. Gardening Shops says:

    Oi! Just what I need to know, Magpie always confused me.

Leave a Reply

Your email address will not be published.


Check out more interesting categories: Blog, Consumer, DIY, Educational, Featured DIYs, Featured Hacks, Featured Web, Hack, HOWTO, Misc, PHP, Projects, Web, Wordpress.


Related News and Resources