Live Category-based OPML template for WordPress 2.0

ok, here’s a little something i’ve been messing with..

i wanted to generate an OPML file based on all the different types of feeds offered with the default WordPress installation. that is, every WP site has a “main” site feed (in rdf, rss, and atom), but there are also category (and subcategory) feeds, as well as feeds for each author. There are even feeds for tags if you use the UTW plugin but i won’t get into that now.

i guess i was originally inspired by the relatively new service offered by Grazr. Add to that the cool things you can do with OPMLBuilder and the awesome potential of Share your OPML..

and well, i got to thinking (more like scheming).

WordPress 2.0 logo
OPML icon
Grazr logo

hmm, the one thing that i couldn’t seem to figure out was why there didn’t seem to be a way to synchronize the feeds in your OPML file and thus ensure that it is always kept up to date. this would make it more useful to me, but i suspect it would be a lot more useful to others too – who in a shared environment (like on Share your OPML) – aren’t necessarily going to know when you add or remove feeds from this your file. essentially, i wanted to be able to create an OPML file, on-the-fly, based on WordPress categorization that would stay current even after i’ve added or deleted categories.

To do this:

  • i created a new WP Template file and called it opml.php
  • i used this new template file to create a WordPress “Page” called opml (you don’t need to put any text in this page just use the OPML Template file (opml.php) instead of the Default Template page and you’re good to go)

What it does:

  • queries the wpdb for all your WP categories (minus any empty categories – ie: ones without posts)
  • excludes any additional categories that you specify (“Uncategorized” is excluded by default)
  • creates a “live” OPML file (actually it’s a URL) based on all your site’s categories but you can easily click on “view source” and copy/paste that code into a local text file (save it as filename.opml)

What you can do with this file:

  • import the OPML into your favorite feedreader (that supports URL imports)
  • create a local OPML file (as described earlier) and import it into your favorite feedreader (that supports OPML file uploads)
  • add your OPML to a directory like Share your OPML ( )
  • use your OPML to browse your site with Grazr

How to get it all working:

  1. download the new template file from here [ opml.phps ] (right-click and choose “Save Link As..” or “Save Target As..”)
  2. rename opml.phps to opml.php and drop it in your template directory
  3. optionally edit the template file to manually add more categories to the exclude list* (other than the default “Uncategorized”)
  4. create your new WP Page and call it “opml” (you can call it anything but in this case the OPML URL would be
  5. make sure that permalinks are turned on (otherwise i doubt any of this will work)
  6. try it out in your feedreader, on Share your OPML, or with Grazr

* the exclude list is just a list of category IDs you don’t want to display and formatted as:
$opmlcatid == ’1′ || $opmlcatid == ’2′ || $opmlcatid == ’3′ || and so on..


  • you can see it all in action on the Indyish Networking page where visitors can use Grazr to quickly browse the entire site for content, feeds, and more.
  • or, embedded right here in this page

Known Issues:

  • [ resolved: see comments ] i’m not an expert php programmer but for some reason there seems to be a problem when using Grazr (in “Slider” mode) where if you drill down into the category and subcategory feeds – navigating backwards becomes a bit retarded. it goes back to the wrong category and all you see is a completely blank page. Fortunately, you can just keep clicking backward (or the “home” icon, or the “refresh” icon) to get to the top of the directory and start over. Furethermore, i temporarily worked around this problem by switching the default view-mode in Grazr, from “Slider” to “Outline”

Up Next:

  1. i’d like to get it to list all author feeds as well [ Update: this is done. just grab opml-authors.phps, rename it to opml-authors.php, and drop it in your WP template directory. then, uncomment the 2nd to last line of php in opml.php ] *This will only select Users who have the “Author” capability in WordPress. Authors without any published posts are excluded by default. You can also exclude other Authors by manually editing opml-authors.php – similar to the way i described earlier
  2. i’d like to get it to list all Links in WP (ie: the default “Blogroll”, and any other link categories you create in the WP backend) [ Update: this is done. just grab opml-links.phps, rename it to opml-links.php, and drop it in your WP template directory. then, uncomment the last line of php in opml.php ] *you can also exclude Link Categories by manually editing opml-links.php – similar to the way i described earlier
  3. i’d like to get it to be a simple WP plugin

if anyone has time, and wants to take a crack at any of these (or if you see any other ways to improve upon any of this i’d love to hear about it – leave lots of comments)

Comments 18

  1. mikepk wrote:

    Very cool use! This exactly the kind of use we hoped people would begin to explore once we released Grazr 1.0. I’m not positive, but I’m guessing the ‘weirdness’ in the slider mode navigation has to do with the OPML file being generated being invalid. We try *really* hard not to be too anal on what we accept for file format, but sometimes things can get tripped up. The opml you’re generating has a <br /> tag at the end of each <outline> node. Technically this isn’t valid opml (although we should be ignoring it). I’m guessing it’s that extra tag that’s causing the slider to act strange. I’ll look into it some more, but again kudos on the really cool use! Soon, we’re going to set up pages on that highlight neat applications like yours.

    Posted 01 Oct 2006 at 2:24 pm
  2. elran wrote:

    thanks mike,

    i figured the weirdness had to do with the OPML file i was generating so i tried to validate it using OPML Validator Beta and it passed without errors. But now i see that in the KB OPML Validator it fails miserably giving errors due to <br /> tags.

    i have no idea why i put those <br /> tags there in the first place. i guess it was pretty late last night and i started playing around with things too much. i’m going to try things again without the <br /> tags and see if the problem is resolved. i’ll also post about it here in the comments and update the download to reflect any changes.

    keep up the good work @ Grazr !

    Posted 01 Oct 2006 at 2:53 pm
  3. elran wrote:

    ok, that didn’t take long..

    you were right mike. got rid of the <br /> tags – the OPML file validates and Slider now works.

    updates the opml.phps file too!

    thanks again -

    Posted 01 Oct 2006 at 3:01 pm
  4. mikepk wrote:

    I’m glad that fixed it, I’ll also check why we’re not ignoring the <br /> tags. When I get a chance I’m going to put a pointer to this on my blog.

    Posted 02 Oct 2006 at 6:07 pm
  5. Scented Candles wrote:

    Can someone help me create an OPML document with my webpages, not feeds. I need it for products, including bath, candles, soaps, etc.


    Posted 27 Oct 2007 at 9:21 pm
  6. nba jerseys china wrote:

    We’re pleased on your behalf due to this reliable information. You really made my best day time :

    Posted 24 Dec 2012 at 4:50 am
  7. Mihran Kalaydjian wrote:

    This paragraph will help the internet users for setting up new web site
    or even a weblog from start to end.

    Posted 01 Feb 2013 at 5:40 am
  8. see driveway wrote:

    Thanks for ones marvelous posting! I seriously enjoyed reading
    it, you will be a great author.I will always bookmark your blog and will
    come back sometime soon. I want to encourage one to continue your great job,
    have a nice day!

    Posted 25 Jul 2013 at 9:31 am
  9. http://green-card- wrote:

    Greetings! Very helpful advice in this particular post!

    It is the littlpe changes that will mqke the biggest changes.
    Many thanks for sharing!

    Posted 21 Sep 2013 at 12:06 pm
  10. http://www.logspec. wrote:

    I’d like to thank you for the efforts you have put in penning this website.
    I really hope to check out the same high-grade content from you later on as well.

    In truth, your creative writing abilities has inspired
    me to get my own, personal blog now ;)

    Posted 30 Aug 2014 at 11:03 pm
  11. See Smolnicky wrote:

    click here

    Posted 21 Dec 2016 at 7:03 pm
  12. Milford Gulliver wrote: does it again! Quite a thoughtful site and a well-written article. Keep up the good work!

    Posted 23 Dec 2016 at 6:54 pm
  13. test wrote:

    I am actually grateful to the holder of thjs web page who has
    shared this woonderful podt at here.

    Posted 04 May 2017 at 9:58 pm
  14. vick strizheus tecademics wrote:

    Gree carpet cleaning product ccan protect the carpet fiberss from stains and
    soils. It must be in a big traffic a portion of thee house, nevertheless, not to where
    itt gets iin the way.

    Posted 22 May 2017 at 4:53 pm
  15. Seth wrote:

    Effective To Help Increase Consumer Response – Postcard Marketing

    Posted 31 May 2017 at 6:04 am
  16. Mozelle wrote:

    They find it very tough too get anything done. It’s difficult to get media photos.
    There is absolutely nothing to it but to
    do it. Each year, you get return invitations, rave reviews,
    and high evaluations.

    Posted 17 Jul 2017 at 7:37 pm
  17. Sharyn wrote:

    Want to reach out peole today during that time period
    off year? Try to avoid picking general categories regarding “Fiction” “General”.
    As a peron see, many methods of incorporating media into on the web.

    Posted 08 Aug 2017 at 2:08 pm
  18. Chem dry melbourne wrote:

    Hi, i feel that i noticed you visited my blog so i got here to ?go back the prefer?.I am trying to
    in finding issues to enhance my website!I guess its ok
    to make use of some of your ideas!!

    Posted 11 Jul 2018 at 6:25 am

Trackbacks & Pingbacks 1

  1. From web 2.0 examples on 17 Dec 2007 at 7:33 am

    web 2.0 examples…

    As usual there is so much talk about Web 2.0 and not many solutions how to really make money with it….

Post a Comment

Your email is never published nor shared. Required fields are marked *