is_post_type_hierarchical()WP 3.0.0

Checks if the post type is hierarchical.

Returned false value might also mean that the post type does not exist.

1 time — 0.000011 sec (very fast) | 50000 times — 0.03 sec (speed of light) | PHP 7.0.2, WP 4.4.2

No Hooks.

Return

true|false. Whether post type is hierarchical.

Usage

is_post_type_hierarchical( $post_type );
$post_type(string) (required)
Post type name

Examples

0

#1 Check whether the post type is hierarchical.

$is = is_post_type_hierarchical('page'); //> true
$is = is_post_type_hierarchical('post'); //> false

Notes

Changelog

Since 3.0.0 Introduced.

is_post_type_hierarchical() code WP 6.4.3

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;
}