WordPress 如何判断一个分类是另一个分类的子分类

WordPress如何判断一个分类是另一个分类的子分类,换句话说就是如何判断一个分类是另一个分类的父分类,官方有这样一个函数cat_is_ancestor_of。

cat_is_ancestor_of( int|object $cat1int|object $cat2 )

参数说明

$cat1

(int|object) (Required) ID or object to check if this is the parent category.

$cat2

(int|object) (Required) The child category.