Update: With the release of SimplePie 1.0, this tutorial became obsolete. Please check out the new tutorial instead.
In this demo, I will show you how to parse multiple feeds and sort all of the posts from all feeds in reverse-chronological order (newest to oldest).
What you’ll need for this demo
- The Multifeeds package
- And, of course, the latest SimplePie for the RSS parsing (1.0 Beta 2 or later)
What you need to do
- Unzip the
- Drop the latest version of
simplepie.incinto the resulting folder.
- Edit — or don’t edit — the index.php file to your heart’s delight. (Maybe you should just let it run untouched the first time.)
- Upload the whole
multifeedfolder to your webserver (or your localhost)
- Set the cache folder to server-writable.
- Load the
index.phpinto your web browser, and voila!
- The very first time you load the page will take more time than the subsequent load will because SimplePie needs to cache all of the feeds for the first time.
- In the feeds you use, make sure that the items in that feed have a published or last modified date associated with them. If not, then those feed items will be shuffled out of order.
- Because SimplePie Beta 3 has support for something called HTTP Conditional Get, cache handling is much improved over Beta 2, leading to better overall performance.