ThemeShaper Forums » Thematic

[closed]

Set up custom single.php

(5 posts)
  • Started 3 years ago by Mike_sa
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. Hi

    I am trying to set up a custom single.php file for a specific category.
    I understood that Thematic theme would look for a slug relating to the post first.

    The category slug is recent-projects . I have created the file single-recent-projects.php and have saved the file to the childtheme.

    When viewing a single post from this category it is not using the single-recent-projects.php file. I am only wanting to remove the sidebar for this category post and leave the side bar for all the other category posts.

    Am I supposed to activate the custom single file somehow?

    I have been trying all sorts of things now for hours and none work. I can't just comment the sidebar out in the main single.php file because I need it for other post categories.

    Help please :)

    Posted 3 years ago #
  2. i'm not sure what is going on w/ your template attempt. my guess (and i can't really see the diagram well at the codex) is that single pages just aren't supported in the way you are attempting.

    http://codex.wordpress.org/Template_Hierarchy

    why not take the functions approach:
    http://forums.themeshaper.com/topic/remove-sidebar

    Posted 3 years ago #
  3. I also would like to have different single.php for different categories. It seems like it can be done with something like this:

    <?php
      $post = $wp_query->post;
    
      if (in_category('1')) {
          include(TEMPLATEPATH.'/single1.php');
      } elseif (in_category('2')) {
          include(TEMPLATEPATH.'/single2.php');
      } else {
          include(TEMPLATEPATH.'/single_default.php');
      }
    ?>

    http://www.wprecipes.com/how-to-use-different-single-template-per-category

    but I can't make it work.

    Posted 2 years ago #
  4. sowingseeds
    Member

    I suspect that TEMPLATEPATH relates to the Thematic directory not to the Child Theme directory?

    Posted 2 years ago #
  5. try:

    add_action('template_redirect', 'kia_template');
    
    function kia_template() {
    	if ( is_single() && in_category('foo'){
    		include (get_stylesheet_directory() . '/single-foo.php');
    		exit();
        } else if ( is_single() && in_category('bar') {
    		include (get_stylesheet_directory() . '/single-bar.php');
    		exit();
        }
    }
    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.