Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tmeyer45458

    (@tmeyer45458)

    The solution:

    <?php
    $in_subcategory = false;
    foreach( (array) get_term_children( 11, 'category' ) as $child_category ) {
    if(in_category($child_category))$in_subcategory = true;
    }
    
    if ( $in_subcategory || in_category( 11 ) ) {
    echo '<span class="fruits">This is about different kinds of fruits</span>';
    } else {
    echo '<span class="bad-cat">Not tasty! Not healthy!</span>';
    }
    ?>

    Figures I find the answer right after asking for help 🙂 Hope this helps someone else!!

    Thread Starter tmeyer45458

    (@tmeyer45458)

    The solution:

    <?php
    $in_subcategory = false;
    foreach( (array) get_term_children( 11, 'category' ) as $child_category ) {
    if(in_category($child_category))$in_subcategory = true;
    }
    
    if ( $in_subcategory || in_category( 11 ) ) {
    echo '<span class="fruits">This is about different kinds of fruits</span>';
    } else {
    echo '<span class="bad-cat">Not tasty! Not healthy!</span>';
    }
    ?>

    Figures I find the answer right after asking for help 🙂 Hope this helps someone else!!

    Thread Starter tmeyer45458

    (@tmeyer45458)

    Problem solved. Too embarrassed to say what it was… 🙂 I should have taken a closer look at the code in archives.php before posting.

    Thread Starter tmeyer45458

    (@tmeyer45458)

    Update: I’ve tried half a dozen themes and in all of them – the categories lead to the desired category and not the homepage.

    So my question is: What, in a theme, could cause the category links to redirect to the homepage? I’m at a loss…

Viewing 4 replies - 1 through 4 (of 4 total)