Try it with:
$current_cat = get_query_var('cat');
if(is_category(3) || cat_is_ancestor_of( 3, $current_cat )) {
// get sidebar for category 3 and all of its children
}
Thread Starter
eable
(@eable)
After I posted I found this description of how to use a post_is_in_descendant_category function.
cat_is_ancestor_of looks useful. Thank you!
I need to make some test cases to feel through how practical application of cat_is_ancestor_of is different from post_is_in_descendant_category. Interesting.
you could always do something like this…..
if ( is_category('catgory1') || is_category('category2) {
get_sidebar('sidebar1');
}
elseif ( is_category('category3') {
get_sidebar('sidebar2')
}
else {
get_sidebar('sidebar3')
}
the || means OR in PHP.
eable… I tried using your conditional statement but can’t seem to get it to work (I’m a newb to php).
I replaced:
<?php get_sidebar(); ?>
with:
<?php if (is_category( array( ‘jewel’, ‘lotus’))) {
get_sidebar(‘JewelsLotus’);
} else
if (is_category( array( ‘almanac’ ))) {
get_sidebar(‘almanac’);
} else {
get_sidebar();
} ?>
Is there something I’m doing wrong, or something more I need to do?