A WordPress-centric search engine for devs and theme authors



wp_get_post_parent_id ›

Since3.1.0
Deprecatedn/a
wp_get_post_parent_id ( $post )
Parameters:
  • (int|WP_Post) $post Post ID or post object. Defaults to global $post.
    Required: Yes
Returns:
  • (int|false) Post parent ID (which can be 0 if there is no parent), or false if the post does not exist.
Defined at:
Codex:

Returns the ID of the post's parent.



Source

function wp_get_post_parent_id( $post ) {
	$post = get_post( $post );
	if ( ! $post || is_wp_error( $post ) ) {
		return false;
	}
	return (int) $post->post_parent;
}