Returns the ID of the post’s parent.
$postint|WP_Post|nulloptional
Default:null
function wp_get_post_parent_id( $post = null ) {
$post = get_post( $post );
if ( ! $post || is_wp_error( $post ) ) {
return false;
}
return (int) $post->post_parent;
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_post_parent_id