If in subcategory of a category?
-
I would like to trigger stuff on my sidebar when the category 6 or it’s subcategories are viewed.
I could do it like this:
<?php if (in_category('6') || in_category('7') in_category('8') in_category('9') in_category('10') in_category('11') in_category('12') { ?> do stuff <?php } ?>
But it’s lenghty, and in time I know I need to ad more subcategories and I would need to edit the template.
in_category article touches the subject a bit. Saying that this should work:
<?php in_category( '6' ) || post_is_in_descendant_category( 6 ) ?>
But being such a neophyte I cant get it to work. All help is generously appreciated! ??
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘If in subcategory of a category?’ is closed to new replies.