这似乎奏效了:
<?php if (is_category( )) {
$thiscat = get_category( get_query_var( \'cat\' ) );
$catid = $thiscat->cat_ID;
//create array from get_category_parents
$parent_list = (explode (\',\',get_category_parents($catid,false,\',\')));
$parent_name = ($parent_list[0]);
$parent = get_cat_ID( $parent_name );
$catlist = get_categories(
array(
\'child_of\' => $parent,
\'orderby\' => \'id\',
\'order\' => \'DESC\',
\'exclude\' => $catid,
\'hide_empty\' => \'0\'
) );
//check if current category is parent category
if ( $catid == $parent ) {
echo \'<span>this is a parent category page</span>\';
}
else {
echo \'<span>this is a child category page</span>\';
}
}
?>