Using WordPress Post Formats to Their Fullest

Post Formats are a really cool feature introduced in WordPress 3.1 that give you the ability to choose the format the post will be outputted in. These “formats” typically refer to the layout of the post content as displayed by the theme on the front end. So, by using Post Formats, you compile a layout that is displayed for all “video” posts, and then a completely different layout for all “image” posts.

Here on WP Roots, for example, there are three post formats:

  • Standard – this is used for all regular posts
  • Video – this is used for all posts that feature a video
  • Link – this is used for all freebies that feature a download

Each of these formats has a predefined style (set by the theme developer) that is automatically applied to the post on the front end.

What I want to show you in this tutorial is how we developers (this will get pretty technical, so beware if you’re not a developer) can utilize post formats to greatly improve our WordPress themes, both in terms of flexibility and end user experience.

1. Enable Post Formats

In order to use post formats, we first have to add support for them to our theme.

001 add_theme_support(
002     'post-formats', array(
003         'aside',
004         'chat',
005         'gallery',
006         'image',
007         'link',
008         'quote',
009         'status',
010         'video',
011         'audio'
012     )
013 );

This will add support for post formats to your theme, and they will be available on the post editor looking like this: