• Resolved intricateartist

    (@intricateartist)


    I’m using the following hack in my single.php:

    <?php
    $post = $wp_query->post;
     if ( in_category(3) || in_category (4) || in_category (6) || in_category (7) || in_category (8) || in_category (9) || in_category (10) || in_category (11) || in_category (12) || in_category (13) || in_category (14) || in_category (15) || in_category (16) || in_category (17) || in_category (18) || in_category (19) || in_category (20) || in_category (21) || in_category (22) || in_category (23) || in_category (24) || in_category (25) || in_category (93)) {
        include (TEMPLATEPATH.'/single-3.php');
    
    } elseif ( in_category('26') ) {
      include(TEMPLATEPATH . '/single-26.php');
    
    } elseif ( in_category('100') ) {
      include(TEMPLATEPATH . '/single-100.php');
    
        return;
    }
    get_header(); ?>

    The problem I’m having is that on single-3.php and single-26.php, there is a post looping at the bottom of the template. Single-100.php and single-php, however, are working exactly as they should. What am I missing? A tick? Paren? Could someone who isn’t cross-eyed have a look for me?

    Thank you in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter intricateartist

    (@intricateartist)

    I’d delete this if I could – I’ve resolved it by creating a new default single post template and adding an “else” into the code above to call it in, clearing the single.php of anything but this hack.

    Sorry, intricateartist, but i’m not sure I followed the solution. Can you break it down a lil more? It sounds like what I am after.

    I think I’d write this differently like so:

    <?php
    $post = $wp_query->post;
    if ( in_category('26') ) {
      include(TEMPLATEPATH . '/single-26.php');
    
    } elseif ( in_category('100') ) {
      include(TEMPLATEPATH . '/single-100.php');
    }
      else {
    include (TEMPLATEPATH.'/single-3.php');
    }
    ?>

    Assuming your single-3.php is your “catch all” template. You don’t need a return or a get_header() in this script. get_header() needs to be in whichever template you are redirecting to.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple Single Post templates/categories’ is closed to new replies.