Child Themes:Adding Post Formats
From StartBox Docs
Contents |
Description
Formatting content differently is now easier than ever thanks to the Post Formats feature added with WordPress 3.1. The following documentation is taken straight from the Post Formats Codex page.
Adding Support
<?php add_theme_support('post-formats', $supported_formats ); ?>
Default Usage
<?php $supported_formats = array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ); ?>
The above example adds support for all of the standard post formats that WordPress supports.
Using Post Formats
In your child theme theme, make use of get_post_format() to check the format for a post, and change its presentation accordingly. Note that posts with the default format will return a value of FALSE. Or make use of the has_post_format() conditional tag:
if ( has_post_format( 'video' )) {
echo 'this is the video format';
}
Styling Post Formats
An alternate way to use formats is through styling rules. Themes should use the post_class() function in the wrapper code that surrounds the post to add dynamic styling classes. Post formats will cause extra classes to be added in this manner, using the "format-foo" name.
For example, one could hide post titles from status format posts in this manner:
.format-status .post-title {
display:none;
}
External Resources
- Post Formats is WP Codex
- Post Types and Formats and Taxonomies, oh my! by Otto
- On standardized Post Formats by Andrew Nacin
- Post Formats vs. Post Types by Mark Jaquith
- WordPress 3.1 Post Formats Reference by Lisa Sabin-Wilson
- Smarter Post Formats? by Dougal Campbell