Post Status

来自WordPress中文文档
跳转至: 导航搜索

WordPress allows you to set a workflow status of the content. The status of a post, as set in the Administration Panel, Write Post SubPanel. Internally, these are all stored in the same place, in the wp_posts table. These are differentiated by a column called post_status.

WordPress 3.0 gives you the capability to add your own custom post status and to use it in different ways.

Default Status

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

Published

Viewable by everyone.

Future

Scheduled to be published in a future date.

Draft

Incomplete post viewable by anyone with proper user level.

Pending

Private

Viewable only to WordPress users at Administrator level.

Trash

Auto-Draft

Inherit

Custom Status

A Custom Status is a Post Status you define.

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