Simple, free resources to help you build a better WordPress website.

Sign up for our newsletter.

A Simple Guide to WordPress Post Formats

We’re hard at work here at UpThemes converting our Tumblr themes over to WordPress and wanted to share some knowledge on the new WordPress 3.1 Post Formats that we’re currently integrating into our themes.

First Things First: What is a Post Format?

A Post Format is a new piece of meta information attached to posts to allow themes to present posts differently than the standard appearance of posts. They are pre-defined, cannot be extended (meaning themers/developers cannot add new ones) and are not enabled by default.

How To Enable Post Formats

Simply drop this into your theme’s init function to enable Post Formats:

add_theme_support( 'post-formats', array( 'aside', 'gallery','link','image','quote','status','video','audio','chat' ) );

Once you add support for Post Formats, you will see a new meta box in the sidebar on your post edit pages like this:

What Can I Do With Them?

Once post formats are enabled, you can now use them in your themes. Two primary functions will come in handy for working with post formats: get_post_format() and has_post_format(). There is also a get_post_format_link() function that allows you to link to a post format archive page for each format.

By using has_post_format(), you simply need to pass in the format you are checking for, then enter some functions into the if statement to handle posts with that post format, like so:

if ( has_post_format( 'image' )) {
  the_post_thumbnail('large');
  echo the_title();
}

If you just want to actually list the post’s format, just use get_post_format() to show the current post format, usually defined in the loop. To show the post format outside of the loop, pass in the post ID like so: get_post_format(45).

Styling Post Formats

Using body_class() and post_class(), you can now take advantage of the new post format classes that are applied to all posts within the loop. Class names will look like this:

  • format-image
  • format-video
  • format-aside
  • format-status

That makes it easy to style your formats to look different and potentially hide or show information relevant to each post type.

So What Are Post Formats Good For? How Are They Useful?

Well, currently post formats are only useful for theme developers to build Tumblelog-style themes and use a standard system that will promote compatibility with other themes. The biggest problem is that theme developers still have to decide how to implement custom Tumblelog functionality and how to embed videos and custom audio players for audio and video content.

For our themes, we’re following the same data architecture as Woothemes’s Wootumblog plugin to ensure we build on a platform that is widely accepted and understood by themers and WordPress users. In addition to being able to use our themes with a site that has previously used a Woothemes Tumblelog theme, we’re also adding support for Express App, which allows iPhone users to publish quickly to WordPress.

9 Comments

  1. Pingback: L’hebdo WordPress : WordCamp Grand Sud – Gravatar – Facebook | WordPress Francophone

  2. Avatar
    Terry Sutton says:

    Hi,

    sorry for the late comment here, but I’ve been trying to figure out how to actually _display_ posts of a certain format for ages.

    Lets say I’ve enabled the ‘status’ post format, and want to display Twitter-like updates in my sidebar. How would I query/display these status updates and put them in the sidebar?

    Perhaps a novice question, but I haven’t found an article describing how this is done.

    Help appreciated!

  3. Avatar
    Jon says:

    I noticed that you are converting tumblr themes to wp, but do the functions stay same (tumblr – picture blog) or they funct. will be regular wordpress.?

    • Avatar

      We are building custom tumblelog integration plus these themes will be fully compatible with Express App and Wootumblog. The functionality is obviously different, but there are still ways to easily publish content, even though it is built on WordPress.

  4. Avatar
    MIke says:

    The only problem with the Woo plugin is that it only supports flash for audio. Tumblr-like themes need HTML5 support with flash fallback so that audio posts can be heard on iOS devices (iPhone, Touch, iPad). Without that – Woo and everyone using their plugin loses me and many other bloggers who would otherwise like a tumblelog theme.

  5. Avatar
    Tom says:

    Do you have to match up the name of your category for each post with the name of one of the nine standard post format names? I have seen examples where some were, and some weren’t, in fact http://themify.me/demo/#theme=wumblr has a few post formats where some posts seem to have different category names.
    Also, I wonder how likely it is that people would select to click on a category where the name is “links” or “status” or “quotes”?

    I would understand if they were likely to click on “video” and “images” etc but even then, that is not very focused on *topics* and does not appear to be good for SEO…what are your thoughts here?

Leave a Reply

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