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}文章。

function is_taxonomy_hierarchical( $taxonomy ) {
	if ( ! taxonomy_exists( $taxonomy ) ) {
		return false;
	}

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

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-29 19:09:56

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: