Summary: Add an RSS feed to a page using SimplePie
Version: 2008-07-28
Prerequisites: PmWiki 2.2beta, PHP, SimplePie (
NOTE: This recipe creates the same (:RSS :) markup as RssFeedDisplay, so do not use it in conjunction with that recipe!
Status: Beta
Maintainer: CRAjr
Categories: RSS, Includes

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

How can I embed RSS feeds from external sites into PmWiki?
How can I specify the number of items in a feed to display (from 1 to the full number available)?
How can I specify the number of characters of a feed item description to display?


SimplePieDisplay is loosely based on the existing Cookbook recipe, RssFeedDisplay, but uses the SimplePie RSS parser rather than Magpie. SimplePie is an open source code library, written in PHP, and provides very granular management of RSS and Atom feeds.


Your host must allow outgoing http requests.

You can test that SimplePie is working correctly and that your host allows outgoing http requests by trying the "sp_compatibility_test.php" that comes with SimplePie. Beware, you cannot run this program from your Cookbook directory because PmWiki doesn't allow direct execution from there. Instead, you'll have to place it elsewhere (perhaps in your web root directory).

This recipe is tested and working properly on all my sites, however I have found a couple of feeds that give it trouble. If you find a feed is not displaying properly, then check in your error logs for clues.

Things that would be useful in a future version:

  1. Enable the ability to show embedded feed images. SimplePie does this correctly, however, SimplePie from within PmWiki does not (or at least not on my sites). Instead, the page generates an "<img src" tag around the existing feed item's "<img src" tag creating an invalid link. I'm not sure what to do about this. In the meantime, I'm utilizing SimplePie's built-in "strip_htmltags" function to strip out the image links before displaying a feed item -- preventing error messages in your logs caused by this problem.
  2. A few feeds, notably, those from FEMA ( contain <pre> tags that override formatting you might want to apply. I'm not a good enough PHP programmer to figure out how to strip the <pre> tags. I've tried the obvious methods "preg_replace" and such, but haven't gotten a workable solution yet. SimplePie's "strip_htmltags" function seems to ignore a request to strip this as well.
  3. SimplePie has the ability to merge several feeds together, then display a sorted list. The list can be full or a subset of items from each feed. Again, this is beyond my current PHP ability to implement.
  4. Currently, the feed item fields (item_url, title, date, description) are hard-coded in the recipe. There is no flexibility for changing the order of how they are displayed. It might be possible to modify the script and add a fourth parameter for "template". This would provide the ability to customize the display location of the fields using a PmWiki template definition from Site.LocalTemplates, for example.


  • Create a new subdirectory in your Cookbook directory. I'm using "cookbook/rss".
  • Download SimplePie (, then extract and install the "" code library file into your "cookbook/rss" subdirectory.
  • Download and install simplepiedisplay.phpΔ into the same directory.
  • Add to your local config file:
  • Edit the simplepiedisplay.php file and change the following four values as needed for your installation:
    • include_once('');
      Location of SimplePie, currently set to same directory as this script
    • $RSS_Cache = '/mnt/data_a/www/cache';
      Location of RSS cache directory, must have write permissions!
    • $Cache_Duration = '1800';
      Interval in seconds before next cache update
    • $Order_By_Date = 'true';
      Order feed items by date? true/false
  • Add the following mark-up to your PmWiki page:
    • (:RSS feed_url show_items_num show_chars_num :)
      where the variables above are as follows:
      • feed_url = the URL of the feed to display
      • show_items_num = number of news items in the feed to display
      • show_chars_num = maximum amount of characters of an item's description to display


This recipe creates a new markup, (:RSS :).
Note: this is the same markup used by RssFeedDisplay, so do not install both recipes at the same time.

To use, find a working RSS or Atom feed URL, then wrap it in the markup like so:

(:RSS 3 10000 :)

I've included some CSS classes so that you can customize the feed item field display:

  • rss_title
  • rss_date
  • rss_description

Release Notes


  • Added the ability to specify the number of items in a feed to display. Any number larger than the available number of items will simply display all items.
  • Added the ability to specify the number of characters in a feed item description to display. Any number larger than the available number of characters will simply display the full description.


  • First version.

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also




21-04-2009 I do not understand how to use the mentioned CSS classes inside a wiki page. Could you please explain a little more how to use the 3 classes inside a wiki. thanks. fabrizio

SimplePie no longer has any .inc files. Since a working .inc isn't included in this package, this becomes unusable as-is. However SimplePie is still in active development (April 2017 last release), unlike Magpie (2005 is the last release) so it may be worth pursuing. XES September 22, 2017, at 04:47 AM

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.