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



wp_get_post_parent_id › WordPress Function

Depuis3.1.0
Dépréciéen/a
wp_get_post_parent_id ( $post = null )
Paramètres:
  • (int|WP_Post|null) $post Optional. Post ID or post object. Defaults to global $post.
    Requis: Non
    Défaut: null
Retourne:
  • (int|false) Post parent ID (which can be 0 if there is no parent), or false if the post does not exist.
Défini(e) dans:
Codex:
Changelog:
  • 5.9.0

Returns the ID of the post's parent.



Source

function wp_get_post_parent_id( $post = null ) {
	$post = get_post( $post );

	if ( ! $post || is_wp_error( $post ) ) {
		return false;
	}

	return (int) $post->post_parent;
}