检查类别是否是另一个类别的祖先。
原型
cat_is_ancestor_of( int|object $cat1, int|object $cat2 )
描述
你可以为两个参数使用id或类别对象。如果使用整数,则将检索该类别。
参数
$cat1
(int|object)
(Required)
用于检查这是否为父类别的ID或对象。
$cat2
(int|object)
(Required)
儿童类别。
返回值
(bool)
$ cat2是否是$ cat1的孩子
源文件
路径:wp-includes/category.php
<?php
...
function cat_is_ancestor_of( $cat1, $cat2 ) {
return term_is_ancestor_of( $cat1, $cat2, 'category' );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/cat_is_ancestor_of/