wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



get_post_parent › WordPress Function

Da5.7.0
Deprecaton/a
get_post_parent ( $post = null )
Parametri:
  • (int|WP_Post|null) $post Optional. Post ID or WP_Post object. Default is global $post.
    Richiesto: No
    Default: null
Ritorna:
  • (WP_Post|null) Parent post object, or null if there isn't one.
Definito a:
Codex:

Retrieves the parent post object for the given post.



Sorgenti

function get_post_parent( $post = null ) {
	$wp_post = get_post( $post );
	return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null;
}