函数原型
cat_is_ancestor_of( int|object $cat1, int|object $cat2 ): bool
函数描述
Checks if a category is an ancestor of another category.
是否弃用
未弃用
函数参数
-
$cat1
int|object
Required - ID or object to check if this is the parent category.
-
$cat2
int|object
Required - The child category.
函数返回值
bool Whether $cat2 is child of $cat1.
函数位置
File: wp-includes/category.php.
函数源码
function cat_is_ancestor_of( $cat1, $cat2 ) {
return term_is_ancestor_of( $cat1, $cat2, 'category' );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |

