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
檢視更多 >