Using WordPress ‘get_post_stati()’ PHP function

The get_post_stati() WordPress PHP function retrieves a list of post statuses.


get_post_stati($args = array(), $output = 'names', $operator = 'and')


  • $args (array|string, Optional) – Array or string of post status arguments to compare against properties of the global $wp_post_statuses objects. Default is an empty array.
  • $output (string, Optional) – The type of output to return, either ‘names’ or ‘objects’. Default is ‘names’.
  • $operator (string, Optional) – The logical operation to perform. ‘or’ means only one element from the array needs to match; ‘and’ means all elements must match. Default is ‘and’.

More information

See WordPress Developer Resources: get_post_stati()


Get all post statuses

Get a list of all registered post statuses.

$post_statuses = get_post_stati();

Get all public post statuses

Retrieve only public post statuses.

$args = array('public' => true);
$public_statuses = get_post_stati($args);

Get post statuses as objects

Get the post statuses as objects instead of names.

$post_statuses = get_post_stati(array(), 'objects');

Get post statuses with ‘OR’ operator

Find post statuses that are either public or private.

$args = array('public' => true, 'private' => true);
$public_private_statuses = get_post_stati($args, 'names', 'or');

Get post statuses with custom properties

Retrieve post statuses with a custom property value.

$args = array('custom_property' => 'custom_value');
$custom_statuses = get_post_stati($args);