WordPress at a glance

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

#1 Check whether the post type is hierarchical.

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

Notes

  • See: get_post_type_object()

Changelog

Since 3.0.0 Introduced.

Code of is_post_type_hierarchical() WP 5.7.1

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

From tag: Custom post type (post_type)

More from tag: Conditional tags (all)

More from category: Custom Types

No comments
    Log In