wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



get_post_parent › WordPress Function

Od5.7.0
Przestarzałyn/a
get_post_parent ( $post = null )
Parametry:
  • (int|WP_Post|null) $post Optional. Post ID or WP_Post object. Default is global $post.
    Wymagane: Nie
    Domyślny: null
Powrót:
  • (WP_Post|null) Parent post object, or null if there isn't one.
Zdefiniowane na:
Codex:

Retrieves the parent post object for the given post.



Źródło

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