wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



get_post_parent › WordPress Function

Desde5.7.0
Obsoleton/a
get_post_parent ( $post = null )
Parâmetros:
  • (int|WP_Post|null) $post Optional. Post ID or WP_Post object. Default is global $post.
    Required: No
    Padrão: null
Retorna:
  • (WP_Post|null) Parent post object, or null if there isn't one.
Definido em:
Codex:

Retrieves the parent post object for the given post.



Fonte

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