//WordPressのカテゴリのテンプレートで、属する親カテゴリに合わせて、
//子カテゴリの内容を切り替える関数
function in_category_family( $parent ) {
if ( empty($parent) )
return false;
if ( in_category($parent) )
return true;
$parent = get_category($parent);
foreach ( (get_the_category()) as $child ) {
$child = get_category($child->cat_ID);
if ( cat_is_ancestor_of($parent, $child) )
return true;
}
return false;
}
//if ( function_exists('in_category_family') && in_category_family('親カテゴリのスラッグ') ){
//実行内容
//}