How to label non-standard post formats in your WordPress 3 RSS feed

In an attempt to try out post formats in WordPress 3, I flagged my last short post as an ‘aside’. It turns out that, in WordPress’s default “Twenty Eleven” template at least, there’s not too much difference between a ‘standard’ post and an ‘aside’ once you get to the individual page, although they are rendered differently on the site’s home page.

That’s a shortcoming in Twenty Eleven, to my mind. I’m in the process of constructing a WP 3.2-compatible template for work, and while we won’t be supporting all of WordPress’s post formats, we’ll need to format entry detail pages, and flag up entries on index pages, depending on which format we use.

For RSS feeds, Tweets, etc., I may want to indicate the type of post format so that readers know what to expect. For example, if an entry has been defined as a Gallery style post format, I may want the RSS reader to display:

Gallery: A selection of pictures

Modifying WordPress’s RSS feeds are slightly trickier than the web pages, as they’re not defined within the theme folder. However, WordPress’s add_filter can come in very useful, as illustrated in this sample code:

Adding this function to my theme’s functions.php means that last week’s aside now shows up in my RSS feed as:

Aside: Park Avenue Cat, Arts Theatre

As far as I’m concerned, this is a temporary fix. It doesn’t do the same for automatically sent tweets going via the plugin I use for that purpose, and there are other places in a template where you’d want to use a similar technique. But it’s a start, and if you’re out there scratching your head and wondering how to tweak your RSS output, hopefully this may give you some clues.

Author: Scott Matthewman

Formerly Online Editor and Digital Project Manager for The Stage, creator of the award-winning The Gay Vote politics blog, now a full-time software developer specialising in Ruby, Objective-C and Swift, as well as a part-time critic for Musical Theatre Review, The Reviews Hub and others.