diff --git a/wp-includes/post.php b/wp-includes/post.php index 3fd27d6823..b26d038186 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -660,6 +660,28 @@ function get_post_stati( $args = array(), $output = 'names', $operator = 'or' ) return $post_statuses; } +/** + * Whether the post type is hierarchical. + * + * A false return value might also mean that the post type does not exist. + * + * @since 3.0.0 + * @see get_post_type_object + * + * @param string|int|object $post Post type name, post id, or a post object. + * @return bool true if post type is hierarchical, else false. + */ +function is_post_type_hierarchical( $post = false ) { + if ( is_string($post) && $is_post_type = get_post_type_object($post) ) + return $is_post_type->hierarchical; + + $ptype = get_post( $post ); + if ( $ptype && $is_post_type = get_post_type_object($ptype->post_type) ) + return $is_post_type->hierarchical; + + return false; +} + /** * Retrieve the post type of the current post or of a given post. *