First day of our Advent Calendar we show tiny code snippets and brief informations for the Post Formats from WordPress version 3.1.
Some theme authors wanted more defined formats – they wanted the feature “post formats”. This new functionality will be available in WordPress 3.1 and displays an additional meta-information. The Codex for this functionality is available already, and now it’s up to the theme authors to use this new feature.
To use this function, you have to activate it with the Theme. This is controlled, similar to other theme features since version 3.0, over a function. The following syntax gives some of the possible post formats and these can then be used directly on the article, as the following screenshot shows.
add_theme_support( 'post-formats', array( 'aside', 'audio', 'image', 'video' ) );
Just put the code into your functions.php of your Themes.
As possible keys are the following values available.
Like in thumblr you can design the according article. Via the defined values you can use this across themes. The format will be output with the function body_class() for instant, which creates a class, which you can access via CSS. An exmaple for the value Aside of the post format.
<body class="single single-post postid-52 single-format-aside">
Alternatively there are conditional tags and functions to get to the assigned type:
As so often depends the creativity and usage on the developer. The biggest benefit is probably that defined values exist and as a theme author you can respond to these formats and as a developer you don’t have to create a new meta box.
Update: The UI received an update, see Andrew’s comment: