Are you using WordPress' Post Formats feature?

If you have upgraded your WordPress installation to the latest version (right now, it’s Version 3.1), you can take advantage of its “Post Formats” feature. So, what is it anyway? WordPress Codex explains:

A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature. Themes are not required to support every format on the list. New formats cannot be introduced by themes nor even plugins. The standardization of this list provides both compatibility between numerous themes and an avenue for external blogging tools to access to this feature in a consistent fashion. In short, with a theme that supports Post Formats, a blogger can change how each post looks by choosing a Post Format from a radio-button list.

This feature might be useful if you want to “format” your blog posts, especially when you want to have different output format from your WordPress theme. Just think about Tumblr service. Tumblr is very easy to use when you want to make a kind of item collections. Sometime you want to embed a video, post a link, make a regular blog post, or even embed an audio file. If you want to create a new post, you will have something like this:


WordPress’s Post Formats will not give you exactly the same posting interface. Basically, it will add another posting menu box. Just select the post formats and that’s the only thing you need to do. So, what’s next? The “post format” will work nicely if you do more creative work on your WordPress theme.

WordPress’ Post Formats supports these following formats: aside, chat, gallery, image, link, quote, status, video, and audio. More details about each format can be found at Codex. If you want, can choose one of the formats for your blog posts.
Now, how to display the “Format” box in the post editing screen? You need to work on your functions.php in your theme directory. If you don’t have that file, create a new one. Simply put this piece of code:
// Add Post Format Support
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio' ) );

The code above will include all post formats. You can choose what kind of formats you can have. Just remove the unused ones.

Now, let’s play with blog theme!

It will be technical, but it’s not difficult. Let me give you a simple example. I want to have my post loop (usually using index.php template file) to be displayed in the following conditions:

  • When I create a “Standard” post, I want to display entry title and posting date. But,
  • When I create a “Link” post, I want to hide the date. Only post title displayed.

So, my entry loop tags will be like this:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>">
<?php
if ( has_post_format( 'link' )) {
echo the_title();
} else {
echo '<h2>';
echo the_title();
echo '</h2>';
echo the_time('F jS, Y');
}
?>
</div>
<?php endwhile; else: endif; ?>

Simple, right? Now, it all depends on how you work with your WordPress theme. :)


Comments

3 responses to “Are you using WordPress' Post Formats feature?”

  1. Yes I do and I’am happy with it ;)

  2. Yeah, I add those to my lovely custom-function.php. BTW, you move to Jakarta bro? Since when? I looking for your Warnadunia but just found the advertise.

  3. i like tmnt