has_post_parent( int|WP_Post|null $post = null ): bool

In this article

Returns whether the given post has a parent post.

Parameters

$postint|WP_Post|nulloptional
Post ID or WP_Post object. Default is global $post.

Default:null

Return

bool Whether the post has a parent post.

Source

function has_post_parent( $post = null ) {
	return (bool) get_post_parent( $post );
}

Changelog

VersionDescription
5.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.