has_post_parent() WordPress Function
The has_post_parent() function in WordPress allows you to check if a post has a parent post. This is useful for checking if a post is a child post or not.
has_post_parent( int|WP_Post|null $post = null ) #
Returns whether the given post has a parent post.
Parameters
Return
(bool) Whether the post has a parent post.
Source
File: wp-includes/post-template.php
function has_post_parent( $post = null ) { return (bool) get_post_parent( $post ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.7.0 | Introduced. |