get_post_status_object

Retrieve a post status object by name.

Description

(object|null) get_post_status_object( (string) $post_status ); 

Returns (object|null)

A post status object.

Parameters (1)

0. $post_status (string)
The name of a registered post status.

Usage

  1. if ( !function_exists( 'get_post_status_object' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // The name of a registered post status. 
  5. $post_status = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_post_status_object($post_status); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function get_post_status_object( $post_status ) { 
  2. global $wp_post_statuses; 
  3.  
  4. if ( empty($wp_post_statuses[$post_status]) ) 
  5. return null; 
  6.  
  7. return $wp_post_statuses[$post_status];