A Guide to WordPress Post Formats

If you purchase through a link on our site, we may earn a commission. Learn more.

Post formats are one of the most interesting additions to WordPress 3.1. In this post we learn how to use them.
Table of Contents
WP Engine High Performance Hosting
BionicWP Hosting

Post formats are one of the most interesting additions to WordPress 3.1.

They enable us to apply different styling to a particular post type (e.g. page or post) by choosing from one of the types provided by WordPress itself:

  • aside –  A short piece of content, typically styled without a title.
  • gallery – A gallery of images.
  • link – A single link to another site.
  • image – A single image.
  • quote – A single quotation.
  • status – A short status update, similar to a Twitter status update.
  • video – A single video.
  • audio – A single audio file.
  • chat – A chat transcript.

How to add Post Format Support

Adding theme support for post formats is very easy, just paste the following into your functions.php file.

[php]add_theme_support(‘post-formats’, array( ‘aside’, ‘chat’, ‘gallery’, ‘image’, ‘link’, ‘quote’, ‘status’, ‘video’, ‘audio’));[/php]

Of course, if you don’t require the full set of post formats, just omit the ones you don’t need from the array.

Now check out your post editor and you will see a new ‘Format’ box in the right hand side bar.

Displaying different Post Formats on your site

In order for your post formats to show up with their own structure and styling on the site, you need to modify your theme. Ideally you use something similar to this code:

[php]
if (have_posts()) :
while (have_posts()) : the_post();
if(!get_post_format()) {
get_template_part(‘format’, ‘standard’);
} else {
get_template_part(‘format’, get_post_format());
}
endwhile;
endif;
[/php]

WordPress will thus check if there are any post formats present, then load the appropriate template according to the format it finds.

Improvements

When Post Formats came out many people were asking why WordPress doesn’t have a customised UI for each Post Format (as is the case with the Tumblr service). This might well be the case in the future, but for now, the format is the same whatever Post Format you choose (Title and Post Editor). If you need a custom UI (especially if you are designing this for a client), the solution can be that of using Custom Meta Boxes. If you need to display different meta boxes for different post formats, a partial solution using JQuery can be found here.

At the moment it is not possible to add any custom post formats, although there is the possibility that the feature might be included in future releases.

If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.

Jean Galea

Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Discover more from our archives ↓

Popular articles ↓

Share Your Thoughts

Your email address will not be published. Required fields are marked *

Claim Your Free Website Tip 👇

Leave your name, email and website URL below to receive one actionable improvement tip tailored for your website within the next 24 hours.

"They identified areas for improvement that we had not previously considered." - Elliot

By providing your information, you'll also be subscribing to our weekly newsletter packed with exclusive content and insights. You can unsubscribe at any time with just one click.