Adding Custom Post Status for Blog in WordPress


Post status can be defined as an editorial tool which tells the WordPress the stage of the blog post which is used during the editing when using WordPress website server hosting. Here the posts are incomplete and is saved with the post status labelled as ‘Draft’. When there is a need to publish the article the status can be changed to published.




Post status helps the WordPress in choosing on how to handle as well display the blog posts on the website. Here it will automatically exclude the posts which is labeled as draft from the homepage and other publicly viewable areas of the website.

The WordPress comes with the following post status which can be used:

Draft is an item which is saved as well as incomplete but not yet published.

In the auto draft option the WordPress will be having the auto save feature which automatically saves the draft as revision.

In the pending reviews the items are complete as well as submitted for the review and is not published.

Future post schedule it to be published later.

In Private the items are marked as private.

In inherit section the child pages automatically inherit the status of the parent page.


Apart from these default post statuses you will be able to create your own custom post statutes for improving the editorial workflow. Here you will be shown on how to create the custom post statuses in WordPress.


Creating the Custom Post Statuses Using the Plugin

This is one of the easiest as well as recommended method for most of the users. Here the customer is allowed to create the custom post statues as well as it efficiently manages the editorial workflow on the multi author WordPress blog. Here the most important thing to perform is to install as well as activate the edit flow plugin.

Upon the activation, the plugin will be adding a new menu item which is labelled as ‘Edit Flow’ to the WordPress admin menu. By clicking on it you will be taken to the plugins settings page.






The edit flow comes with a lot of useful features, and one can turn them On/Off from their screen. Now you need to click on the ‘Edit Statuses’ button which is under the ‘Custom Statuses’ box to continue.

 

Here the edit flow automatically creates the following custom post statuses:

Pitch is used to pitch the new article ideas and the statuses and it also becomes the default post status of every new post.

You will be able to select the author and then mark the article as assigned so that the author is able to work on it.

In progress section the writer is working on the post but is not available as a readable draft.







You will be able to create an own custom status just by providing the name as well as description in the left column. Once it is done you need to click on the ‘Add new status’ button for saving the changes. Here the custom status will be appearing in the right hand side so that you will be able to edit as well as delete whenever you require.


 



Now you will be required to go to the Posts >> Add New page for creating a new post. Now on the post edit screen you need to click on the edit link which is next to the status options which is under the ‘Publish’ meta box.





Here it will be revealing the dropdown menu which shows all the post statuses so that you can select the custom post status you have already created.  You will be able to see all the articles which is filed under different post statuses just by visiting the Posts » All Posts page.





Adding the Custom Post Statuses using the Code

There is a known bug in the API user interface for registering the custom post statuses. This allows the user in creating the custom post status, but this cannot be used in the admin panel. This would mean that the coding method can make the job done but it won't be as clean as you would require after it has been officially fixed.

This is one of the method which requires to add the codes to the WordPress website. Here the following code needs to be added to the theme functions.php file or a website specific plugin.

 

// Registering custom post status

function wpb_custom_post_status(){

   register_post_status('rejected', array(

       'label'                    => _x( 'Rejected', 'post' ),

       'public'                    => false,

       'exclude_from_search'       => false,

       'show_in_admin_all_list'    => true,

       'show_in_admin_status_list' => true,

       'label_count'               => _n_noop( 'Rejected <span class="count">(%s)</span>', 'Rejected <span class="count">(%s)</span>' ),

   ) );

}

add_action( 'init', 'wpb_custom_post_status' );

 

// Using jQuery to add it to post status dropdown

add_action('admin_footer-post.php', 'wpb_append_post_status_list');

function wpb_append_post_status_list(){

global $post;

$complete = '';

$label = '';

if($post->post_type == 'post'){

if($post->post_status == 'rejected'){

$complete = ' selected="selected"';

$label = '<span id="post-status-display"> Rejected</span>';

}

echo '

<script>

jQuery(document).ready(function($){

$("select#post_status").append("<option value=\"rejected\" '.$complete.'>Rejected</option>");

$(".misc-pub-section label").append("'.$label.'");

});

</script>

';

}

}

One should never forget to replace all the instances of the word rejected with your own custom post status. Here code will register a custom post status and after that it will be using jQuery for adding it to the admin panel. You will now be able to edit the WordPress post, moreover you will also be able to see the status drop-down menu.





You can contact us anytime and choose our WordPress Hosting services. All our WordPress hosting plans are economical. We provide the best 24*7 support to our customers.