Almost all blog software and blog sites have feeds that list the latest blog posts. An easy way to keep visitors updated on your site is to also list the blog posts. This article goes over how to add a PHP script to your website to list the latest blog posts.

  • Download the Magpie RSS Feed display tool
  • Create a rss subdirectory in your site and expand the contents of the Magpie software into that directory.
  • Include the rss feed reader at the top of the page you want the feed to display.
    <?php include("rss/"); ?>
  • Paste the following code where you want the blog feed to display on your site.
    	// RSS Feed from Blog
    	$num_items = 5;
    	$rss = fetch_rss('your_feed_url_here');
    	$items = array_slice($rss->items, 0, $num_items); 
    	echo "
    "; echo "

    My Blog Feed

    \r\n"; echo "
      "; foreach ($items as $item) { $href = $item['link']; $title = $item['title']; echo "
    • $title
    • "; } echo "
    "; echo "
    "; ?>
  • Now locate the link to your blogs RSS feed. This is usually indicated by a link like “Feed” “RSS” or “Subscribe.” Right click on it and copy the link and then paste in the spot in the code from above where it says your_feed_url_here.
  • You can now publish the updated page to your site and view the feed. You can also modify the feed to display the way you want. The Magpie website and zip contain some more detailed examples.

Happy blogging!