Put this in a hacks or plugin file. Then just do <?php if (in_category_recursive_up(24)) {
It works by first checking the categories that they post has for a match. It then takes each category and "digs up" (basically asking each one, "who's your daddy?") until it either runs out of categories (false) or finds a match (true). I haven't tested it too much, but initial tests indicate that it works.
function in_category_recursive_up($cat_id=0) {
if ( !is_single() )
return false;
$cats = get_the_category();
if ( !count($cats) ) // error: no cats defined!
return false;
foreach ( (array) $cats as $cat ) {
if ( $cat->cat_ID == $cat_id ) { // match!
return true;
}
if ( in_category_dig_parents($cat->category_parent, $cat_id) )
return true;
}
return false;
}
function in_category_dig_parents($cat_id, $look_for) {
if ( !$cat_id )
return false;
if ( $cat_id == $look_for )
return true;
$cat = get_category($cat_id);
return in_category_dig_parents($cat->category_parent, $look_for);
}