is_taxonomy_hierarchical()
is_taxonomy_hierarchical( string $taxonomy )
确定分类对象是否分层。
Determines whether the taxonomy object is hierarchical.
说明(Description)
检查以确保分类法首先是一个对象。然后获取对象,最后返回对象中的层次结构值。
错误的返回值也可能意味着分类法不存在。
有关此主题函数和类似主题函数的更多信息,请参阅主题开发人员手册中的条件标记文章。
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$taxonomy | (string) | 必需 | 分类对象的名称。 |
返回(Return)
(bool)分类法是否分级。
源码(Source)
/** * Whether the taxonomy object is hierarchical. * * Checks to make sure that the taxonomy is an object first. Then Gets the * object, and finally returns the hierarchical value in the object. * * A false return value might also mean that the taxonomy does not exist. * * @since 2.3.0 * * @param string $taxonomy Name of taxonomy object. * @return bool Whether the taxonomy is hierarchical. */ function is_taxonomy_hierarchical($taxonomy) { if ( ! taxonomy_exists($taxonomy) ) return false; $taxonomy = get_taxonomy($taxonomy); return $taxonomy->hierarchical; }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.3.0 | wp-includes/taxonomy.php:310 | 20 | 2 |
is_taxonomy_hierarchical() 为WP2原创文章,链接:https://www.wp2.cn/functions/is_taxonomy_hierarchical/