is_taxonomy_hierarchical

函数
is_taxonomy_hierarchical ( $taxonomy )
参数
  • (string) $taxonomy Name of taxonomy object.
    Required:
返回值
  • (bool) Whether the taxonomy is hierarchical.
定义位置
相关方法
is_post_type_hierarchicalis_taxonomy_viewableis_taxonomy_wp_ajax_add_hierarchical_term_get_term_hierarchy
引入
2.3.0
弃用
-

is_taxonomy_hierarchical是一个WordPress函数,用于检查给定的分类法是否是分层的。它接受一个参数,即分类法的名称,如果分类法是分层的,则返回布尔值true,否则返回false。

确定分类法对象是否是分层的。

首先检查以确保分类法是一个对象。然后获取该对象,最后返回该对象中的层次值。

一个错误的返回值也可能意味着该分类法不存在。

关于这个和类似的主题函数的更多信息,请查看《主题开发者手册》中的{@link Conditional Tags}文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_taxonomy_hierarchical( $taxonomy ) {
if ( ! taxonomy_exists( $taxonomy ) ) {
return false;
}
$taxonomy = get_taxonomy( $taxonomy );
return $taxonomy->hierarchical;
}
function is_taxonomy_hierarchical( $taxonomy ) { if ( ! taxonomy_exists( $taxonomy ) ) { return false; } $taxonomy = get_taxonomy( $taxonomy ); return $taxonomy->hierarchical; }
function is_taxonomy_hierarchical( $taxonomy ) {
	if ( ! taxonomy_exists( $taxonomy ) ) {
		return false;
	}

	$taxonomy = get_taxonomy( $taxonomy );
	return $taxonomy->hierarchical;
}

常见问题

FAQs
查看更多 >