My First Post Format

Posted on

By Michael Fields

Post formats are an exciting new feature that will be available in WordPress 3.1. In my opinion the use of post formats will fundamentally change the way in which many people post content to their site. I say this because I have noticed a change in how I approach publishing content since I have started thinking about using them and (as of this morning) started using them on my own site. The reason is simple: post formats enable you to add context to you posts without affecting other organizational structures like categories and tags. I can’t tell you how many hours I have spent in the past creating complex hierarchies with categories to achieve similar functionality. Thankfully, these days are over!

There are 9 different post formats

  1. aside
  2. audio
  3. chat
  4. gallery
  5. image
  6. link
  7. quote
  8. status
  9. video

What about good ‘ole regular posts?

These will be given a format of Standard.

Hey what’s the deal? There are no formats on my site.

At the moment this is most likely because this is a feature that will be available in a future version of WordPress. If you are running 3.0 or below, you will not be able to use post formats. If you have version 3.1+ installed, this feature should be available.

I’m running 3.1 – Still no Formats!

This is most likely because the theme you have installed does not support post formats. This feature is completely dependent on a theme’s ability to present posts having different formats in a unique way. If your theme does not support post formats, it is really, really easy to add support. Add the following line of code to your theme’s functions.php file:

add_theme_support( 'post-formats', array( 'status' ) );

This will enable you to choose a format of status when you publish your posts. It is possible to add all of the other formats as well but I would only suggest doing this if you plan to use them and create unique templates for their display:

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

There are so many, How do I decide?

The choice of which formats to use is really up to you. You know better than anyone else what kind of content you create. Personally I chose to use only 1 format on my site so far: status. I would have used link as well, but I already have a custom post_type set up for that which works pretty well.

Why I chose status

I chose status because I felt that its presence would trick me into posting more content. The Codex defines a status post as “A short status update, usually limited to 140 characters. Similar to a Twitter status update”.

When I get the urge to post something to my site, it takes me a bit of time to sit down and write it. A bit more time than I would like to admit honestly! In my experience this sometimes means that I do not have the time to really do a good job and I don’t post anything at all.

I hope that having a status format will lift the burden of trying to write a 2 – 3 thousand word essay that goes into as much detail as possible about a certain topic and allow me to express my ideas in a short, straight-to-the-point manner.

View my first status post.

Formatting a status post

Since WordPress suggests that a status post is somewhat like a tweet, I decided to style mine to look a bit like Twitter.

I thought that having my picture next to the post would be a good idea and adding a Gravatar to loop was cake. Only one line of code is necessary:

<div class="avatar"><?php print get_avatar( $post->post_author, $size = '60' ); ?></div>

Add a Title?

I’ve seen a few examples of other early adopters of post_formats leaving out the title. I think that it is beneficial to have a title. When I think about it, if Twitter allowed us to post titles, I would probably do it + if you look at their design, they are using titles, but the titles are the user’s name. I decided to conditionally use the post’s title. If I type one in, it will appear, if not, then it won’t. Flexibility. It’s a good thing (yep, I went there). Here’s the code I am using for titles:

$title = get_the_title();
if ( ! empty( $title ) ) {
	the_title( '<h2 class="name"><a href="' . get_permalink() . '">', '</a></h2>' );

If you would like to use the author’s name instead of the title of the post, you could use the following code instead:

print '<h2 class="name"><a href="' . get_permalink() . '">' . get_the_author() . '</a></h2>';

If you would like to use the author’s name as the title but link to a page displaying all of their posts, use the following code:

<h2 class="name"><?php the_author_posts_link(); ?></h2>

Get Creative!

There are lots of ways to style different formats. See what others are doing and mix and match different ideas. Let your imagination fly!

If you are using post formats, consider writing a post about it and leave a link in my comments section. Would love to hear about interesting ideas surrounding this functionality.

Useful Functions

has_post_format( $format )
A conditional function that returns true if the post has a certain format.
Returns the format of the current post.
get_post_format_link( $format )
Return the url to the post formats archive page.

Further Reading

  1. Official Codex Documentation by Codex Volunteers
  2. WordPress 3.1 Post Formats Reference by Lisa Sabin Wilson
  3. Post Formats vs. Custom Post Types by Mark Jaquith
  4. Smarter Post Formats by Dougal
  5. Intro to Post Formats in WordPress 3.1 by Gil Rutkowski
  6. Post Formats Explained by James Huff

3 Comments Comments are closed

  1. John Flower December 20, 2010 at 9:59 am

    So, for instance, on Silly Poetry, where the content centres on images, I’d choose a post format of “image”, right? Also, if you choose a post format, how far may you deviate from the one you choose? If you chose image, but added some text, does that matter?

  2. Michael Fields December 20, 2010 at 10:09 am

    Yes I think that it would be a great idea to use post formats to display the image posts on your site. At the moment, the theme is in complete control over what is displayed so if the template file allows the post_content to be displayed, then it will be displayed.

    A neat idea that comes to mind immediately is the ability to add extra information that only makes sense on an image post. For instance, if you upload really large images and always display the “medium” sized image in your posts, it might make sense to include a “view full-size image” button for image. I’m sure there are other ideas as well.

    Another cool reason to use the image post format is WordPress will automatically create archives for each different format. Here’s a link to all of my status posts. You might notice that the title’s a bit ugly at the moment, but I spent some time in trac earlier today helping to solve the problem. You should not have to worry about this once 3.1 hits the shelves.

  3. John Flower December 20, 2010 at 10:15 am

    Cool. Thanks Michael. Will start looking into post formats. I think I need more WordPress intro teaching first though. Might be a case of trying to walk before I crawl. Good info nonetheless. Thanks. Great work.

Fork me on GitHub