/ Published in: PHP
URL: http://codex.wordpress.org/Function_Reference/get_term_children
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
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; }
You need to login to post a comment.
