I have been using WordPress since 2004/2005 – and when new features come out, sometimes it takes time to implement them in new and existing websites you work on. When custom post types came out with WordPress 3.0 – I have to admit it took 3-6 months to start regularly using them in my work. At first I used custom code, and later some plugins to save time managing them.
When custom post types came out it changed the game for WordPress because it allowed you to organize the content using a taxonomy. It was also helpful because it segregated content in the wp-admin dashboard to new sections (so all posts weren’t mixed in the same places sorted only by tags and categories). It made things easier to find, easier to manage and edit.
What are Post Formats?
With WordPress 3.1 came the addition of “Post Formats“, which is functionality that allows you change the display of post content on the front end (dependent on the type of content). While custom post types are widely used – I have to admit that post formats haven’t really seem to catch on the same way custom post types have. There seems to be some confusion as to what they can actually be used for, and since support for them has to be added to your theme – it’s a barrier keeping some website owners from using them (unless you use the default themes).
A “post format” is something that’s used by a WordPress theme to determine how to display the content (of that post). It only works with normal posts – not custom post types. Have you ever had trouble making sure certain things in posts displayed the way you wanted? Like video, audio, lists, images, galleries, or other unique kinds of content?
Let’s say you have a normal WordPress website, and you’re using the default 2010 or 2021 theme (or soon to come 2021).
In the image above you’ll see what you see (by default) on the right side of the edit page for a post for available “post formats” in the 2021 theme. When writing a new post, the format you choose determines how the theme will display it. Standard is a normal post, an aside is a post with no title, gallery is for images, status is like Facebook, etc.
If you’re still confused I suggest reading this Post Formats vs. Custom Post Types post by Mark Jaquith. He sums it up by saying that post formats “are for posts (only)” (not for custom post types) – things that would “appear in your feed”.
Also in Andrew Nacin’s post about Standardized post formats he says:
The idea behind the feature is this standardization and portability for a segment of bloggers. Many designers of themes used for microblogging wanted this ability to offer structured, well-defined content, beyond what could be done with categories and tags.
How do you enable post formats in a WP theme?
In our example above we used the default 2021 WordPress theme because it has post formats built in. If you wanted to add support for post formats inside a different WordPress theme you would need to enable it like this in your functions.php file like this:
inside the array in that code you can specify what post formats your theme would support. So if you also wanted video it would be ‘aside’, ‘gallery’, ‘video’, etc.
From the official Codex Post Formats page here is a list of supported formats:aside – Typically styled without a title. Similar to a Facebook note update.gallery – A gallery of images. Post will likely contain a gallery shortcode and will have image attachments.link – A link to another site. Themes may wish to use the first a href=”” tag in the post content as the external link for that post. An alternative approach could be if the post consists only of a URL, then that will be the URL and the title (post_title) will be the name attached to the anchor for it.image – A single image. The first tag in the post could be considered the image. Alternatively, if the post consists only of a URL, that will be the image URL and the title of the post (post_title) will be the title attribute for the image.quote – A quotation. Probably will contain a blockquote holding the quote content. Alternatively, the quote may be just the content, with the source/author being the title.status – A short status update, similar to a Twitter status update.video – A single video. The first tag or object/embed in the post content could be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL. May also contain the video as an attachment to the post, if video support is enabled on the blog (like via a plugin).audio – An audio file. Could be used for Podcasting.chat – A chat transcript
So the content of your post doesn’t change at all with a post format, you still use the same edit screen with title, content area, tags, categories, or different attributes for custom post types. What changes is the way that post is displayed in your theme depending on which format you choose. A theme doesn’t have to support all the post formats listed above, you could choose to support just the ones you need.
Post Format Theme Examples
In a way post formats pay homage to WordPress roots as a blogging tool. If you are using WordPress for blogging, then post formats enable you to post content more like you would be used to at say Facebook, Twitter, Tumblr, Posterous, etc. It allows status and ‘microblogging’ types of formatted content to be easily displayed, and well as media handling for podcasts, video blogging, images and galleries, etc. So a blogger will get good usage out of these features.
However, where post formats shine is when it gives you the ability to better segregate and categorize content for display. It the past you might have had to assign content to specific categories to get this done, and then write custom code or page templates with conditional tags. You might have written PHP code to say “if it’s in this category, use this layout”, etc.
The image above is for the Wumblr theme – which directly shows how post formats can work in a theme layout. In tumblr like fashion you can see this theme supports all 9 types of post formats, each formatted to specifically that type of content. This theme not only styles each post format differently, but color codes them as well. You can see in the image above audio, video, gallery, image, aside, quote, standard, etc.
In the image above we see a link post format at the popular “Digging into WordPress blog. When you visit their website, you’ll also find that clicking the title of any link post (or text) takes you to another site, NOT a single post page. This is a great example of how you might microblogging content like this in your feed, but there is absolutely no need for each post to have it’s own single page.
WP Charity is a free 2010 child theme with styled post formats. In the image above you can see that each post format has it’s own identifying icon. View the image above to see some example posts and icons.
Manually Adding Post Format Support to Existing Themes
There are WordPress functions you can use within a theme to work with post formats, such as get_post_format, and has_post_format. In your index.php or home.php you could add code like this to determine which post format is shown:
While that code will work just fine – it might be better (more efficient) to use get_template_part like this:
Once your theme recognizes when a particular post format is used, your stylesheet.css for the theme needs to address the appropriate elements. This is where the WordPress reference post_class comes in handy. Post class is great – it automatically prints out CSS classes for things in “the loop” when you use it.
In a div you might use it like this:
<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
In other words, in the HTML code of a webpage if a video post format was shown the div container would look like this:
In your stylesheet.css you need to make entries for the post formats your theme will support and style them accordingly, like .format-video, .format-link, etc.
Then post formats are printed in code as the class selector “format-name”.
Plugins for Post formats
Now that we’ve explained what post formats are, shown theme examples, and how to add them to your own theme – we’re going to talk about some post format plugins that can be very useful.
Post Formats Widget is a plugin that places a widget in your sidebar with a list of your post formats (the same way a categories widget would work). If you’re going to regularly use post formats in your blog – this is a great way to let somebody view just one type of post like video, image, link, etc.
Post Format Permalink is a handy plugin is you’re using post formats, because you can enable the post format to be included in your permalink.
Once enabled, all you have to do is add %format% to your permalink structure, so your URL would be site.com/link/post-name, etc.
WP Post Formats is a helpful plugin that allows you to control what is displayed in your post format using a plugin rather than having to change your theme code.
In the image above you can see how templates and tags and used for the 9 available post formats. Simply use the tags for what to include in each, and you can easily control what included. You might want to have for example titles in some (but not others), or add or remove time, thumbnail, etc.
WP Post Formats Admin UI is a plugin by well respected plugin author Alex King of Crowd Favorite. It’s not often I link a plugin not in the official WP repository – but this plugin is an exception.
In the image above you’ll see that the plugin actually changes the layout of a standard post by adding tabs at the top for the post format. When you choose a particular format, it actually changes the fields you can fill out (for that format).
The caveat here is that you’ll have to have some knowledge of how to properly implement this in your theme, you’ll want to start out by reading this blog post first.
Set Aside is a plugin for changing post formats. You can switch all the posts in one category from one post format to another.
How, Why, and When to Format Posts without Post Formats
Post formats are great for blogs, for displaying microblogging content inside a blog – as well as video, audio, images, etc. They are also limiting in the regard that you cannot add or edit the 9 WordPress post formats without changing WordPress core files (which you never want to do). If post format functionality works within the scope of your website – by all means use them. You can enable any or all of the 9 formats you need to use to format your content.
If you need additional functionality outside of what post formats provide, think about using specific plugins or a theme to fulfill your needs instead. There are certain things to consider in this scenario as well.
The Notebook Theme is a great example. You install the theme, and everything is taken care of for you – from stylesheet to theme code, and even some meta boxes for image, audio, and video. This premium theme does use standard post formats, but if you choose to change your theme in the future that’s all you will retain (you’ll lose all front end style and formatting).
Other themes with formatting and functionality for specific types of posts (like links, images, video, statuses) may NOT use normal WordPress post format code. Migration from a theme like that to a new theme would mean losing the front end formatting and style, AND all the post format categorization as well. You would essentially be married to that theme unless you decided to re-assign a post format manually to all your posts (in a new theme).
If you chose to handle post formatting using plugins, then you don’t have to worry about being tied to a theme – but you could be tied to plugins (which may or may not be supported in the future). Using the plugin approach another issue is, you may not be able to find one single plugin to handle what you need for all your posts types. You will probably need a plugin for image gallery’s, another for video galleries or embedding, and other plugins to handle things like the microblogging elements. A plugin like Simple Microblogging comes to mind.
However you chose to format your posts you just need to weigh your options carefully – thinking about what you might need in the future. It might also be helpful to create a test or dev blog to begin to setup and use these options on a trial basis.
Happy post formatting!