0

I don't understand what "Adding Post Type Support" is for when we have "Adding Theme Support"?

For different post-formats this is the way I was shown before. This is then how I did it for the project I was working on, is this a correct/good way to do it?

here is whats in my functions.php file:

<?php add_theme_support( 'post-formats', array('image', 'video', 'gallery')); ?>

and here is what is in my index.php file:

<?php get_template_part('content', get_post_format()); ?>

I also want to know if I should "custom post type" for what I describe below:

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?

4
  • 3
    "Also how do I make pages display posts." - This is a different question entirely. Please post it as a separate question (but be sure to search the site for related questions first.) Nov 29, 2012 at 17:44
  • 1
    "Is it possible to have a "Supported Format" be used more than once" - I don't understand this question at all. Nov 29, 2012 at 17:45
  • 1
    I still don't understand what you mean by "use the supported format more than once". Are giftshop and newsletter custom post types? Nov 29, 2012 at 17:59
  • 1
    There is no need to delete the content of this question, only to rewrite it in a new question. That's what question edits are for. Nov 29, 2012 at 18:25

1 Answer 1

3

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 {}
3
  • 1
    I added some comments to your question, related to your edits. Nov 29, 2012 at 17:45
  • Where should I start now that we have the question figured out? Nov 29, 2012 at 21:50
  • See Targeting post formats via CSS. Nov 29, 2012 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.