wp_get_post_parent_id
Return the post's parent's post_ID.
Description
(int|false) wp_get_post_parent_id( (int) $post_ID );
Returns (int|false)
Post parent ID, otherwise false.
Parameters (1)
- 0. $post_id (int)
- The post id.
Usage
if ( !function_exists( 'wp_get_post_parent_id' ) ) { require_once ABSPATH . WPINC . '/post.php'; } // The post id. $post_id = -1; // NOTICE! Understand what this does before running. $result = wp_get_post_parent_id($post_id);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/post.php
- function wp_get_post_parent_id( $post_ID ) {
- $post = get_post( $post_ID );
- if ( !$post || is_wp_error( $post ) )
- return false;
- return (int) $post->post_parent;
- }