/ Published in: PHP
wordpress in subcategory
Expand |
Embed | Plain Text
<?php function is_subcategory ($id) { $in_subcategory = false; if( in_category($child_category) ) { $in_subcategory = true; } } return $in_subcategory; } ?> <?php if ( is_category(1) || is_subcategory(1) ) { ?> ....LOOP.... <?php } ?>
Comments
Subscribe to comments
You need to login to post a comment.

I wasn't finding getcategorychildren() in WP 2.8.4, so I did:
function insubcategory( $catid ) { $subcats = gettermchildren( $catid, 'category' ); if ( $subcats && !iswperror( $subcats ) ) { foreach( $subcats as $childcategory ) { if( incategory($childcategory) ) { return true; } } } return false; }