The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] Displaying post types differently in WordPress

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #26306

    I think the easiest way to describe what I’m trying to do is compare it to the Twenty Ten theme. In that if a post has a category of “aside” or “gallery” it’s automatically displayed differently on the index page (or any page that calls the loop) because the loop is chopped up to do this. So that’s what I’m trying to do, except instead of having different formatting for certain categories have it for certain custom post types. I’m certain there’s something to do this but I just can’t figure it out. In the loop.php of Twenty Ten it uses “in_category” and I think that’s just the bit that needs changing but I can’t figure out to what. Or maybe there’s an easier way to do this whole thing and I’m just going at it backwards.


    Do you just want to have category-x to be styled differently than category-y in the WP loop?


    No I’m sorry if I phrased it poorly, I want to have post type-x be styled differently than post type-y.

    Chris Coyier

    For styling the individual pages in that category, you can actually use files in your theme like category-{slug}.php and WordPress will automatically use that template. For styling on pages like index.php, yes, definitely the in_category() logic is the way to go, like:

    // ouput stuff

    } else {

    // default styling

    } ?>

    I’m not trying to style different categories though, but different post types. So a post type of “movies” would display differently than just a normal “post”.


    As far as I know, there is no conditional tag for “is_post_type” any longer…but I think this is what you are looking for:

    Not sure if Chris has a more efficient method or not…


    That looks like what I’ve been searching for. I’ll try it out. Thanks.


    OK so I tried a variation of the above but now I’m getting an error: Parse error: syntax error, unexpected ‘<' in index.php on line 12. Line 12 is

    and has never caused any problems before but now with if/elseif statements it’s causing a problem for some reason. This is a sample of the code now:

    if ( 'movie_review' == $post_type ) {


    Oops, figured it out. I didn’t close the php before putting in the html.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Back End’ is closed to new topics and replies.