Uses
Uses | Description |
---|---|
wp-includes/post.php: get_post() | Retrieves post data given a post ID or post object. |
wp-includes/load.php: is_wp_error() | Check whether variable is a WordPress Error. |
Returns the ID of the post’s parent.
(int|WP_Post) (Required) Post ID or post object. Defaults to global $post.
(int|false) Post parent ID (which can be 0 if there is no parent), or false if the post does not exist.
File: wp-includes/post.php
function wp_get_post_parent_id( $post ) { $post = get_post( $post ); if ( ! $post || is_wp_error( $post ) ) { return false; } return (int) $post->post_parent; }
Version | Description |
---|---|
3.1.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_post_parent_id