wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



get_post_parent › WordPress Function

Depuis5.7.0
Dépréciéen/a
get_post_parent ( $post = null )
Paramètres:
  • (int|WP_Post|null) $post Optional. Post ID or WP_Post object. Default is global $post.
    Requis: Non
    Défaut: null
Retourne:
  • (WP_Post|null) Parent post object, or null if there isn't one.
Défini(e) dans:
Codex:

Retrieves the parent post object for the given post.



Source

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