wp_get_post_parent_id( int|WP_Post $post )

Returns the ID of the post’s parent.


Description Description


Parameters Parameters

$post

(int|WP_Post) (Required) Post ID or post object. Defaults to global $post.


Top ↑

Return Return

(int|false) Post parent ID (which can be 0 if there is no parent), or false if the post does not exist.


Top ↑

Source Source

File: wp-includes/post.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
3.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.