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 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:
<li><h2>Blogroll</h2> <?php { include('opmlSidebar.php'); $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); ?> <?php } ?> </li>
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.
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
Thanks, jtintle. I hope you find this useful. Please let me know about your experience using it.
Ok I finally got around to trying this out on my test WP blog at http://jtintle.com/. I just can’t seem to get the the blogrolls to expand. Seems we would also need the ExpandCollapse script maybe.
ok I found the expand script by looking at your source…it works just trying to modify it a bit for what i want to use it for
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.
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
I’m closing comments here and referring everyone to the plugin page: OPML Renderer.