Prepare your RSS feed for post formats

WordPress 3.6 Post Formats UI

Post formats are an excellent way to display different kinds of information in the manner most appropriate for the information being presented.

For example, I have used post formats on both my personal blog and my daughter’s blog to change the display of each post depending on whether the post contains an image, gallery, video, quote, or a number of other things.

The thing is, it is your theme that determines how to display the information. So when your post format is set to “image” for example, your theme changes the layout of the post to make the image more prominent.

Your RSS feed however, is very different. It is very unlikely that your theme accounts for modifying the layout of your RSS feed.

When you create a video post, your theme might ask that the video be included in some metadata and not within the post content, and so since the RSS feed just includes the post content and not any metadata, it is unlikely that the video will even be shown.

So on my sites, I made some adjustments to make the RSS feed a little more user friendly.

The following code checks whether each post is a specific post format, and if it is, it modifies the layout to account for the different post formats. Because this functionality is directly tied to your theme, it belongs in functions.php:

In each instance, if there is a featured image, it’s added to the top of the post. Secondly, in certain instances (if the post format is gallery, audio, or video) a sentence is added to the top of the post which points out that the user can view the gallery, video or audio directly on the website.

Depending on your specific needs, you could quite easily modify this code to suit your own site and theme, using the same principles shown here.

Leave a Reply