如何检测当前页面是否为产品子类别页面?
我尝试过以下内容,但它总是打印出“否”
function is_subcategory($category = null) {
if (is_category()) {
if (null != $category){
$cat = get_category($category);
}else{
$cat = get_category(get_query_var(\'cat\'),false);
}
if ($cat->parent == 0 ){
return false;
}else{
return true;
}
}
return false;
}
if (is_subcategory()){
echo "YES";
}else{
echo "NO";
}