How to Add a Custom Post Status to Quick Edit

I think you can find a lot of good information about status creation in WP. But I didn’t find any notes about how to add a status (custom status, you just created) into inline post edit.

inline quick edit in WordPress

So, I mean this dropdown list:

Post Statuses In WordPress Quick Edit

As you can see, there are only 4 WordPress default common statuses. And when you create your own status with register_post_status() function, it won’t appear there.

function rudr_custom_status_creation(){
	register_post_status( 'featured', array(
		'label'                     => _x( 'Featured', 'post' ), // I used only minimum of parameters
		'label_count'               => _n_noop( 'Featured <span class="count">(%s)</span>', 'Featured <span class="count">(%s)</span>'),
		'public'                    => true
	));
}
add_action( 'init', 'rudr_custom_status_creation' );

Okay, let’s stop talking and start doing this. I want to show you the code which allows you to add your custom post status into quick edit dropdown.

add_action('admin_footer-edit.php','rudr_status_into_inline_edit');
 
function rudr_status_into_inline_edit() { // ultra-simple example
	echo "<script>
	jQuery(document).ready( function() {
		jQuery( 'select[name=\"_status\"]' ).append( '<option value=\"featured\">Featured</option>' );
	});
	</script>";
}

Some comments for the code:

WordPress inline post edit with you custom status in dropdown

I also recomment you to add the following hook into your functions.php to display the custom post status label like this:

custom post status label in WP

The code:

function rudr_display_status_label( $statuses ) {
	global $post; // we need it to check current post status
	if( get_query_var( 'post_status' ) != 'featured' ){ // not for pages with all posts of this status
		if( $post->post_status == 'featured' ){ // если статус поста - Архив
			return array('Featured'); // returning our status label
		}
	}
	return $statuses; // returning the array with default statuses
}
 
add_filter( 'display_post_states', 'rudr_display_status_label' );

That’s it. Please leave comment if you have a question.

Thanks for reading.

Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X