Show Latest Blog Posts on any PHP page

You can use magpie to display your latest blog posts on any php page, so a site without a blog can still display posts from any blog that has an RSS feed. Magpie tutorials on the net usually don’t take into consideration quotes which we have here, so this should be all you need to get going.

Magpie & RSS

If you’ve come to this page you probably already use magpie, if not, magpie is an RSS parser that can be used to display your blog posts on any php page. You can get Magpie here

image of a magpie, it's a black and white bird with a sharp beak

Complete Code

You don’t need to know what any of this stuff means really, just change path/that/points/to/magpie/rss_fetch.inc to be the actual path to that file on your server, set the $url variable to point to your RSS feed, and $num_items sets the number of posts you want to see.

The Curly Quote Fixes

If you already use magpie to display your blog posts and just need to fix your quotes, then you would just add these pieces from the code above to your code:

and

If you run PHP5 on your server, it comes with it’s own simple to use parser called SimpleXML which you could use instead of magpie, we’ll show you how to do that in a future article, so subscribe to our feed if you want to be notified.

Topics covered:
Enable Javascript