• I have this code in my “Single.php”:

    <?php
    if ( in_category('3') ) {
    include 'single_article.php';
    }
    elseif ('category_parent=9') {
    include 'single_teacher.php';
    }
    else {
    include (TEMPLATEPATH . '/index.php');
    }
    ?>

    And it work’s great to make every post under category3
    use “single_article.php” and every post under the category 9 or under one of it’s subcategories use the “single_teacher.php”.

    But when I try to add another template for posts
    under category 15 or it’s subcategories like that:

    <?php
    if ( in_category('3') ) {
    include 'single_article.php';
    }
    elseif ('category_parent=9') {
    include 'single_teacher.php';
    }
    elseif ('category_parent=15') {
    include 'videolessons.php';
    }
    else {
    include (TEMPLATEPATH . '/index.php');
    }
    ?>

    It’s just take the “single_teacher.php” even
    for the posts under category 15.

    Any Idea?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Is the category also a child of category 9 (id of 9) though?…

    If it is, that’s why you have that problem, because the you get a match on the first elseif, so you never reach the next one…

    Thread Starter Begin

    (@bentalgad)

    No, it isn’t.

    Well exactly is this anyway?

    elseif ('category_parent=9')

    Unless you’re passing that information along to something, that on it’s own doesn’t do anything, or shouldn’t really do much anyway.

    Thread Starter Begin

    (@bentalgad)

    Sorry I didn’t really understand what your saying ??

    What does this refer to?
    elseif ('category_parent=9')

    If category_parent ( what’s category_parent ? ).

    As is, that’s just a string of text that doesn’t necessarily mean anything.

    Thread Starter Begin

    (@bentalgad)

    It is it means: chack if the post your on,
    is in a category that is a subcategory of category9,
    and it works!

    Sorry that’s my point, that code won’t do that..

    Where did you take that code form?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problem with link posts to category template’ is closed to new replies.