WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Post Status

Posts in WordPress can have one of a number of statuses. The status of a given post determines how WordPress handles that post. For instance, public posts viewable by everyone are assigned the publish status, while drafts are assigned the draft status. The status is stored in the post_status field in the wp_posts table.

WordPress provides 8 built-in statuses you can use. WordPress 3.0 gave you the capability to add your own custom post status and to use it in different ways.

Workflow

WordPress provides built-in features that empower some users (based on their Roles and Capabilities) to review content submitted to the website before it is published. This is commonly called "workflow." WordPress's workflow features rely on the value of a post's post_status field to know which step in the workflow process the post is currently held in.

Most users are already familiar with at least two workflow states:

  • Posts that are published and visible to everyone (including users who are logged out) are given the publish status.
  • Drafts that are not yet published are assigned the draft status.

Internally, WordPress sets the post status to publish when you click the "Publish" button, and WordPress sets the post status to draft when you click the "Save Draft" button. Similarly, if your website has users granted the edit_posts capability but not the publish_posts capability, then when those users start writing a new post, WordPress will display a "Submit for Review" button instead of a "Publish" button. Likewise, WordPress then assigns the post that user created the pending status when they press that button.

The status of a post can also be set in the Administration Screen and Add New Posts Screen by any user with the capability needed to assign the post to the given status. Internally, all of these posts are stored in the same place (the wp_posts table), and are differentiated by a column called post_status.

Default Statuses

There are 8 major post statuses that WordPress uses by default.

Publish

Viewable by everyone. (publish)

Future

Scheduled to be published in a future date. (future)

Draft

Incomplete post viewable by anyone with proper user role. (draft)

Pending

Awaiting a user with the publish_posts capability (typically a user assigned the Editor role) to publish. (pending)

Private

Viewable only to WordPress users at Administrator level. (private)

Trash

Posts in the Trash are assigned the trash status. (trash)

Auto-Draft

Revisions that WordPress saves automatically while you are editing. (auto-draft)

Inherit

Used with a child post (such as Attachments and Revisions) to determine the actual status from the parent post. (inherit)

Custom Status

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

A Custom Status is a Post Status you define. It should not be longer than 20 characters, otherwise the post could not insert or update into the database.

Adding a custom status to WordPress is done via the register_post_status() function. This function allows you to define the post status and how it operates within WordPress.

Here's a basic example of adding a custom post status called "Unread":

function 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', 'custom_post_status' );

Resources

Related

Code Documentation