WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/register post status

Contents

Description

Register a post status.

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.

This function should not be called before the 'init' action.

NOTICE:
This function does NOT add the registered post status to the admin panel. This functionality is pending future development. Please refer to Trac Ticket #12706. Consider the action hook post_submitbox_misc_actions for adding this parameter.

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: true
show_in_admin_status_list
(bool) (optional) Show in the list of statuses with post counts at the top of the edit listings, e.g. All (12) , Published (9) , My Custom Status (2) ...
Default: true
label_count
(array) (optional) The text to display on the admin screen (or you won't see your status count). Array should be in the same format as _n_noop() output.
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