fris
By: a guest | Mar 19th, 2010 | Syntax:
None | Size: 0.56 KB | Hits: 94 | Expires: Never
<?php
// functions.php file in your theme directory
// In wordpress no such function exists, only is_category(), with this you can take advantage of this incase you need to check for it.
function is_subcategory ($id) {
$in_subcategory = false;
foreach( explode( "/", get_category_children($id) ) as $child_category ) {
if( in_category($child_category) ) {
$in_subcategory = true;
}
}
return $in_subcategory;
}
?>
// theme code
<?php if ( is_category(1) || is_subcategory(1) ) { ?>
<-- loop -->
<?php } ?>