Understanding Post Formats/Custom Post types Etc

Please refer to the Post Formats Codex entry.

Post Formats are a Taxonomy

Keep in mind that, under the hood, post formats are simply a taxonomy with a fancy UI and wrapper functions.

add_theme_support()

The add_theme_support( 'post-formats' ) call tells WordPress that the current Theme supports the core Post Formats feature. Basically, it tells WordPress to expose the Post Formats meta box on the post-edit screen.

List of supported post formats

Supported formats can only include the limited set of post formats (i.e. the set of post_format taxonomy terms) defined by core:

  • aside
  • gallery
  • link
  • image
  • quote
  • status
  • video
  • audio
  • chat

get_template_part()/get_post_format()

The <?php get_template_part('content', get_post_format()); ?> call is used in the template to include a template-part file named content-$format.php, and will fallback to include content.php if the current post does not have a post format assigned.

add_post_type_support()

I don’t understand what “Adding Post Type Support” is for when we have “Adding Theme Support”?

By default, post formats only apply to the post (i.e. blog post) post-type. You can use add_post_type_support( $posttype, $feature ) to add support for that feature to the specified post-type. For example, to add post-format support to the page (i.e. static page) post-type:

add_theme_support( 'page', 'post-formats' );

Targeting post formats via CSS

Lets say I have a page called “giftshop” with posts (also trying to figure that part out now) and I want to use the image format for each post but then I have a page that I’m only going to show one post called “newsletter” and I also want to use the image format but have it styled a little different, is that possible?

This is entirely possible, via CSS.

First, be sure that your Theme uses both the body_class() and the post_class() template tags.

Then, assuming you’re using a custom page template, with a filename template-giftshop.php, you can target that page specifically via the body.page-template-template-giftshop-php CSS class.

Then, assuming you’re targeting the image post-format, and your loop markup includes something like the following:

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

…the post_class() template tag will add a .format-$format CSS class. So, you can target the image post format via .format-image.

Thus, you can target posts with the image post format specifically on pages that have the template-giftshop.php custom page template assigned like so:

body.page-template-template-giftshop-php .format-image {}

Likewise, you can target posts with the image post format specifically on pages that have the template-newsletter.php custom page template assigned like so:

body.page-template-template-newsletter-php .format-image {}