wordpress / latest / functions / has_post_parent.html

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

Returns whether the given post has a parent post.

Parameters

$post int|WP_Post|null Optional
Post ID or WP_Post object. Default is global $post.

Default: null

Return

bool Whether the post has a parent post.

Source

File: wp-includes/post-template.php. View all references

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

Uses

Uses Description

Changelog

Version Description
5.7.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/has_post_parent