get_post_parent() WordPress Function
The get_post_parent() function is used to retrieve the ID of the parent post of the current post.
get_post_parent( int|WP_Post|null $post = null ) #
Retrieves the parent post object for the given post.
Parameters
Return
(WP_Post|null) Parent post object, or null if there isn't one.
Source
File: wp-includes/post-template.php
function get_post_parent( $post = null ) { $wp_post = get_post( $post ); return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.7.0 | Introduced. |