OPML Sidebar for WordPress

If you look in the right column running down the main page of this website (the sidebar), you'll notice a heading for my "Blogroll." And if you examine the blogroll, you may notice this little graphic OPML graphic that says OPML. That's because my blogroll is being generated on-the-fly from my OPML reading lists generated by PodNova and NewsGator.

Here is the PHP code for the OPML sidebar and the XSL stylesheet that generates an HTML list for the blogroll.

To use this hack, you'll need to save opmlSidebar.php in your theme directory. You'll also need to create two subdirectories in your theme directory, _cache and xsl, and save opmlSidebar.xsl in the xsl subdirectory. You will probably need to change the directory permissions of the _cache directory to be world readable and world writeable (i.e., CHMOD 777).

In addition, somewhere in your sidebar.php file (or whatever file it is in your theme that generates your sidebar), you'll need to add code something like this for each OPML file you want to include:

$xslfile = dirname(__FILE__).'/xsl/opmlSidebar.xsl';
$opmlfile = '{URL FOR YOUR OPML FILE}';
$opmlname = '{NAME FOR YOUR OPML FILE}';
$file = checkCache($opmlfile);
renderOPML($file, $opmlfile, $xslfile);

I only recently started using WordPress, so I haven't had time to get into the Plugin API, yet. But I wanted to publicize this hack.

Please leave a comment if you want to discuss this hack.


  1. This looks like an interesting hack. I have just started trying to understand OPML and how it will do anything for me…now I found a way to add it to my WP site…thank you

  2. Pingback: frEdSCAPEs
  3. Jtintle – I’ve been tweaking this a bit, but I’ve yet to update my post to reflect the changes. In fact, I’m going to revise the XSL to generate the JavaScript. It’ll be more portable that way. Stay tuned.

  4. You betcha, I’ll keep an eye out,plus I have you in my sage feeds.
    Now I just have to figure a way to have my WP blog automatically create a OPML file of my posts

Comments are closed.