is_post_type_hierarchical

函式
is_post_type_hierarchical ( $post_type )
引數
  • (string) $post_type Post type name
    Required:
返回值
  • (bool) Whether post type is hierarchical.
相關
  • get_post_type_object()
定義位置
相關方法
is_post_type_archiveis_post_type_viewableis_taxonomy_hierarchicalget_post_type_archive_linkpost_type_archive_title
引入
3.0.0
棄用
-

is_post_type_hierarchical – 這個函式檢查一個給定的文章型別是否是分層的。如果文章型別是分層的,它返回true,否則返回false。

確定文章型別是否是分層的。

一個錯誤的返回值也可能意味著該文章型別不存在。

function is_post_type_hierarchical( $post_type ) {
	if ( ! post_type_exists( $post_type ) ) {
		return false;
	}

	$post_type = get_post_type_object( $post_type );
	return $post_type->hierarchical;
}

常見問題

FAQs
檢視更多 >