Title: has_post_parent
Published: March 9, 2021
Last modified: May 20, 2026

---

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

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#wp--skip-link--target)

Returns whether the given post has a parent post.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#parameters)󠁿

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
|nulloptional

Post ID or [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
object. Default is global $post.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#return)󠁿

 bool Whether the post has a parent post.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/post-template.php#L2085)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/post-template.php#L2085-L2087)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#related)󠁿

| Uses | Description | 
| [get_post_parent()](https://developer.wordpress.org/reference/functions/get_post_parent/)`wp-includes/post-template.php` |

Retrieves the parent post object for the given post.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/has_post_parent/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.7.0](https://developer.wordpress.org/reference/since/5.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fhas_post_parent%2F)
before being able to contribute a note or feedback.