Function Reference/register post status
Description
Register a post status. Do not use register_post_status before init.
A simple function for creating or modifying a post status based on the parameters given. The function will accept two parameters; a string for the post status name and an array of arguments.
Usage
<?php register_post_status( $post_status, $args ); ?>
Parameters
- $post_status
- (string) (required) Name of the post status.
- Default: None
- $args
- (array|string) (optional) An array of arguments for this post status.
- Default: None
Arguments
- label
- (string) (optional) A descriptive name for the post status marked for translation.
- Default: $post_status
- public
- (bool) (optional) Whether posts of this status should be shown in the front end of the site.
- Default: false
- exclude_from_search
- (bool) (optional) Whether to exclude posts with this post status from search results.
- Default: false
- show_in_admin_all_list
- (bool) (optional) Whether to include posts in the edit listing for their post type.
- Default: false
- show_in_admin_status_list
- (bool) ( Published (9) ) Show in the list of statuses with post counts at the top of the edit listings, e.g. All (12)
- Default: My Custom Status (2) ...
- label_count
- (string) (optional) The text to display on the admin screen (or you won't see your status count).
- Default: None
Example
An example of registering a post status called "Unread":
function my_custom_post_status(){
register_post_status( 'unread', array(
'label' => _x( 'Unread', 'post' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Unread <span class="count">(%s)</span>', 'Unread <span class="count">(%s)</span>' ),
) );
}
add_action( 'init', 'my_custom_post_status' );
Change Log
Source File
register_post_status() is located in wp-includes/post.php
Resources
Related