get_post_status

Definition:
function get_post_status($ID = '') {}

Retrieve the post status based on the Post ID.
If the post ID is of an attachment, then the parent post status will be given instead.

Parameters

  • int $ID: Post ID

Return values

returns:Post status or false on failure.

Source code

function get_post_status($ID = '') {

	$post = get_post($ID);



	if ( !is_object($post) )

		return false;



	if ( 'attachment' == $post->post_type ) {

		if ( 'private' == $post->post_status )

			return 'private';



		// Unattached attachments are assumed to be published

		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )

			return 'publish';



		// Inherit status from the parent

		if ( $post->post_parent && ( $post->ID != $post->post_parent ) )

			return get_post_status($post->post_parent);

	}



	return $post->post_status;

}

1609

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: