Skip to content
wp-skills
Register
tools/wordpress-post-status-generator

WordPress Post Status Generator

WordPress Post Status Generator is a tool that helps you to generate custom post statuses for your WordPress projects.

Not register_post_status: naming the callback after the core function it calls is a fatal redeclaration.

Your theme or plugin's own domain, for the two labels below.

Stored in wp_posts.post_status, a varchar(20) — a longer key is truncated by the database and stops matching the one the code registered. Slugged and clipped for you.

The label, and the singular half of the “(%s)” count above the posts list.

The plural half of that count. English needs both spellings; _n_noop() picks between them per language.

Whether posts in this status are visible to visitors who are not logged in.

Whether these posts appear in the unfiltered list, alongside published and draft ones.

Adds it to the “All | Published | Draft” row of links above the list, with a count.

Keeps these posts out of front-end search results even when the status is public.

snippet.php
function wp_skills_custom_post_status(): void {
	$args = array(
		'label'                     => __( 'Draft', 'text-domain' ),
		'label_count'               => _n_noop( 'Draft (%s)', 'Drafts (%s)', 'text-domain' ),
		'public'                    => true,
		'show_in_admin_all_list'    => true,
		'show_in_admin_status_list' => true,
		'exclude_from_search'       => false,
	);

	register_post_status( 'my_status', $args );
}
// Priority 0 so the status exists before anything queries by it.
add_action( 'init', 'wp_skills_custom_post_status', 0 );

// Note: register_post_status() makes the status usable, but WordPress does not
// add it to the status dropdown in the editor. Doing that needs its own script
// on the edit screen, or a block editor plugin.