get_post_status_object( string $post_status ): stdClass|null

Retrieves a post status object by name.

Description

See also

Parameters

$post_statusstringrequired
The name of a registered post status.

Return

stdClass|null A post status object.

Source

function get_post_status_object( $post_status ) {	global $wp_post_statuses;	if ( empty( $wp_post_statuses[ $post_status ] ) ) {	return null;	}	return $wp_post_statuses[ $post_status ]; } 

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Examples

    $obj = get_post_status_object( 'publish' ); echo esc_html( $obj->label );

    Alternatively, it also works like this:

    global $wp_post_statuses; $obj = $wp_post_statuses['publish']; echo esc_html( $obj->label );

    print_r( $obj ) looks like this:

    stdClass Object ( [label] => Published [label_count] => Array ( [0] => Published (%s) [1] => Published (%s) [singular] => Published (%s) [plural] => Published (%s) [context] => [domain] => ) [exclude_from_search] => [_builtin] => 1 [public] => 1 [internal] => [protected] => [private] => [publicly_queryable] => 1 [show_in_admin_status_list] => 1 [show_in_admin_all_list] => 1 [date_floating] => [name] => publish )

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