/ Published in: PHP
Usually use in a template with `in_category()`, like `if ( in_category( 3 ) || in_subcategory( 3 ) ) { ...`. Tested in WP 2.8.4.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function in_subcategory( $cat_id ) { $subcats = get_term_children( $cat_id, 'category' ); if ( $subcats && !is_wp_error( $subcats ) ) { foreach( $subcats as $child_category ) { if( in_category($child_category) ) { return true; } } } return false; }
URL: http://codex.wordpress.org/Function_Reference/get_term_children