Creating Custom Post Status in WordPress

by Vincy. Last modified on July 13th, 2022.

WordPress post status is used to describe the state of the post. There are various default post statuses in WordPress to represent the post states.

In this tutorial, we are going to see those default states and also, how to create a custom post status. In a previous tutorial, we have already seen about how to create a custom taxonomy if that’s what you are looking for and landed here.

There are plugins available in the WordPress market that provides the feature to create custom post status. For example, the Edit Flow plugin, WordPress Status Planer plugin supports provides support to create custom post status.

But, such plugins provides many features that are over and above our simple requirement. If creating custom post status is the only requirement you have, then for that simple purpose loading a plugin that provides a suite of services would be a waste on resources.

So, let’s go the custom way, creating custom post status via functions.php is quite easy or you may even bundle it as a tiny custom plugin and use it. I registered the custom post status In Writing in my theme’s functions.php.

I used the WordPress action hook to call the function to register the custom post status. But, there is an issue with creating custom post status via programming, that is, the registered custom post status cannot be seen in the WordPress admin.

This screenshot shows the registered custom post status in the wp-admin post edit form.


So, while editing the post we cannot set the custom post status for the posts. I have embedded a script to add the newly registered custom post status to the post edit form status dropdown.

WordPress Default Post Statuses

This section shows the list of available WordPress post status comes with its core data. These statutes describe the state of the WordPress post.

  • Publish – can be viewed by all.
  • Future – Scheduled to be published at a future date.
  • Draft – A post that is not complete yet and can be viewed by the people who have proper privileges.
  • Pending – Ready and waiting for a user who has the privilege to publish it.
  • Private – Can be viewed only by the Admin level users.
  • Trash – Deleted posts.
  • Auto Draft – Automatic revisions created by the WordPress during the process of editing.
  • Inherit – Used with the dependent posts like attachments.

These post statuses are more than enough to manage the editing process of the WordPress post and carry it from one state to another. If you want to create your own post statuses with meaningful names then the upcoming section will help you to achieve it by custom coding.

Registering Custom Post Status using functions.php

I have register my own post status named as ‘In Writing’ by setting the default options. This code specifies the default options for registering the custom post status.

This function will be invoked by using the WordPress action hook. In the default specification, I have added the post status caption, enable/disable the directive flags to control the visibility of the posts under this status.

// Register Custom Post Status
function register_custom_post_status(){
    register_post_status( 'In Writing', array(
        'label'                     => _x( 'In Writing', 'post' ),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'In Writing <span class="count">(%s)</span>', 'In Writing <span class="count">(%s)</span>' ),
    ) );
add_action( 'init', 'register_custom_post_status' );

Display Custom Post Status in WordPress Admin Edit Form

As we have mentioned about the issue of viewing the registered custom post status in wp-admin, I have embedded a script to append the newly created post status options in the status dropdown while editing the post.

// Display Custom Post Status Option in Post Edit
function display_custom_post_status_option(){
    global $post;
    $complete = '';
    $label = '';
    if($post->post_type == 'post'){
        if($post->post_status == 'in-writing'){
            $selected = 'selected';
echo '<script>
$("select#post_status").append("<option value=\"in-writing\" '.$selected.'>In Writing</option>");
$(".misc-pub-section label").append("<span id=\"post-status-display\"> In Writing</span>");
add_action('admin_footer', 'display_custom_post_status_option');
Written by Vincy, a web developer with 15+ years of experience and a Masters degree in Computer Science. She specializes in building modern, lightweight websites using PHP, JavaScript, React, and related technologies. Phppot helps you in mastering web development through over a decade of publishing quality tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *

↑ Back to Top

Share this page