cat_is_ancestor_of()
cat_is_ancestor_of( int|object $cat1, int|object $cat2 …
cat_is_ancestor_of( int|object $cat1,  int|object $cat2 )
检查一个类别是否是另一个类别的祖先。
Check if a category is an ancestor of another category.
检查一个类别是否是另一个类别的祖先。
Check if a category is an ancestor of another category.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
两个参数都可以使用id或category对象。如果使用整数,则将检索类别。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 | 
|---|---|---|---|
| $cat1 | (int | object) | 必需 | 要检查这是否是父类别的ID或对象。 | 
| $cat2 | (int | object) | 必需 | 子类别。 | 
返回(Return)
(bool)是否$cat2是$cat1的子级
源码(Source)
/**
 * Check if a category is an ancestor of another category.
 *
 * You can use either an id or the category object for both parameters. If you
 * use an integer the category will be retrieved.
 *
 * @since 2.1.0
 *
 * @param int|object $cat1 ID or object to check if this is the parent category.
 * @param int|object $cat2 The child category.
 * @return bool Whether $cat2 is child of $cat1
 */
function cat_is_ancestor_of( $cat1, $cat2 ) {
	return term_is_ancestor_of( $cat1, $cat2, 'category' );
}| 更新版本 | 源码位置 | 使用 | 被使用 | 
|---|---|---|---|
| 2.1.0 | wp-includes/category.php:232 | 0 | 1 function | 
笔记(Notes)
基本示例
类别:WordPress 函数手册、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。







还没有任何评论,赶紧来占个楼吧!