Support » Fixing WordPress » Custom Post Type Category Template

  • swcomm


    I want to use a completely different single.php template (which uses a different header, footer and css file) for one category within a custom post type. This custom post type already has a single.php template separate from the rest of the site. I tried a category template, but I think because the posts in this category are also included in other categories, I’m not getting the results I want. Taxonomy doesn’t really seem to fit the situation, so I’m not sure how to do this. Advice? Thanks.

Viewing 1 replies (of 1 total)
  • vtxyzzy


    You might be able to use this approach.

    You did not give the custom post type name, so assume it is ‘custom’ and your special category is ‘special’ with id = 6.

    • Rename single-custom.php to single-custom-default.php.
    • Create a new single-custom-special.php template for the custom posts in the special category.
    • Create a new single-custom.php template and use code similar to the following.
    // single-custom.php is now in single-custom-default.php
    // We want to use single-custom-special for category 'special' (id = 6).
    $post = $wp_query->post;
    if ( in_category(array(6) )) {
      include(TEMPLATEPATH . '/single-custom-special.php'); }
    else {
      include(TEMPLATEPATH . '/single-custom-default.php');
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type Category Template’ is closed to new replies.