get_post_statuses()
Returns an array of the following basic post statuses: Draft, Pending, Private, Publish.
The returned array differs in translation (localization).
To get an array of all statuses, including those registered by the function register_post_type(), use the function get_post_stati().
This function retrieves a hard-coded list of statuses (see the function code). This list does not include dynamically added statuses, such as 'future'.
To see a list of all statuses used in your WordPress build, use get_post_stati().
No Hooks.
Returns
String[].
array(
'draft' => __('Draft'),
'pending' => __('Pending Review'),
'private' => __('Private'),
'publish' => __('Published')
);
Usage
get_post_statuses();
Examples
#1 Get all registered post statuses
$statuses = get_post_statuses(); /* $statuses will contain such an array: Array ( [draft] => Draft [pending] => On approval [private] => Personal [publish] => Published ) */
#2 Get all statuses including custom ones
add_action( 'init', function () {
global $wp_post_statuses;
var_dump( $wp_post_statuses );
// result... with 'custom_status'
/*
array(
"publish",
"future",
"draft",
"pending",
"private",
"trash",
"auto-draft",
"inherit",
"custom_status" // <-- here we go
)
*/
}, PHP_INT_MAX );
Referenced from: https://wordpress.stackexchange.com/a/331154
#3 Hard-coded list WARNING
Note that this function returns a hard-coded list of statuses. This list is missing core statuses such as future.
To actually see the list of all post statuses available in your WordPress instance, use get_post_stati().
Changelog
| Since 2.5.0 | Introduced. |
get_post_statuses() get post statuses code WP 7.0
function get_post_statuses() {
$status = array(
'draft' => __( 'Draft' ),
'pending' => __( 'Pending Review' ),
'private' => __( 'Private' ),
'publish' => __( 'Published' ),
);
return $status;
}