• Hi all,

    seems I need a little help in thinking my way through wordpress …

    I’m running a site with book reviews. For this purpose, I use a custom fields widget to show ISNB, publisher, number of pages etc. for every post (= every review). This works great, but I now need a second post type that’s completely different from this one.

    I read about the difference between custom post types and post formats and I think I need the formats in order to show up in my RSS feed as well. I also breifly read about customizing the output of different post formats.

    My question is: Is it really possible to edit the output of the post formats so detailed? E. g., I don’t want the custom fields to show up on the new post format and the featured image must have completely different dimensions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Well, you could choose “image” as the format for the new post format, then you make a template which displays only the data you want. In your single.php template you can query the post format, and then get a different template depending on what’s been chosen in the admin area, using get_template_part(); E.g;

    $format = get_post_format( $post->ID ) ? get_post_format( $post->ID ) : 'standard' ;

    get_template_part( 'post', $format );

    The template would be called post-standard.php if no format was selected. Hope that helps..

    Thread Starter wutzelmutz

    (@wutzelmutz)

    Thanks for your answer.

    Just to get that right: I’ll use the single.php as the basis for every post and implement the query there to check if the post format is ‘standard’ or ‘image’. Depending on the query, it then loads the correct template.

    So in fact I don’t have to deal with the output of the format itself in the single.php since this can take place in the templates themselves?

    Well, using that code inside the single.php template will allow you to “include” whatever template you want to process the post inside the loop. Where possible it’s pretty cool to use get_template_part(), because it means you can “share” the code between different templates. Best thing to do is experiment a bit, what I’ve shown you should be enough to get you started. Check out the functions on the Codex, and if you’re still stuck, post some code back here so I can take a peek.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post types vs post formats’ is closed to new replies.