In this article, we’ll learn about how to create Create Custom Post Status in WordPress.
Table of Contents
WordPress post status is used to describe the state of the post.
WordPress is undoubtedly one of the most popular content management systems, empowering millions of websites worldwide. While it offers a wide range of built-in functionalities, there are times when you may want to extend its capabilities to suit your specific needs. One such feature is the ability to create custom post status in wordpress.
WordPress comes with a number of built-in post statuses, such as “Draft,” “Pending Review,” “Published,” and “Trash.” However, you may find that you need to add your own custom post statuses to better track the progress of your content.
For example, you might want to create a custom post status for “In Review” or “Awaiting Approval.” This can help you to keep track of the different stages of your content creation process and ensure that nothing falls through the cracks.
WordPress posts can have by default 8 number of post statuses. The status of a given post determines how WordPress handles that post. For instance, public posts viewable by everyone are assigned the publish status, while drafts are assigned the draft status. The status is stored in the post_status field in the wp_posts table.
Followings are some of built-in post status:
- Draft: Incomplete posts viewable by anyone with proper user level.
- Future: Scheduled posts to be published on a future date.
- Pending: Awaiting approval from another user (editor or higher) to publish.
- Published: Live posts on your blog that are viewable by everyone.
- Private: Posts that are viewable only to WordPress users at Administrator level.
- Trash: Deleted posts sitting in the trash (you can empty the trash to delete them permanently).
- Auto-Draft: Revisions that WordPress saves automatically while you are editing.
Benefits of Custom Post Status in WordPress:
-
Improved Workflow Management: With custom post status in wordpress, you can design a workflow that aligns perfectly with your content creation and publishing process. Whether you need to denote posts as “In Progress,” “Under Review,” or “Archived,” custom statuses provide clear visibility into each stage.
-
Enhanced Organization: As your website grows, managing a large volume of content can become overwhelming. Custom post statuses offer a valuable organizational tool by categorizing posts based on their specific status. This makes it easier to find and filter posts, saving you time and effort.
-
Content Tailored to Your Needs: Every website is unique, and so are its content requirements. Custom post statuses enable you to create tailored statuses that fit your niche. Whether you run an eCommerce site and need “Out of Stock” or “Pre-order” statuses, or manage a community platform that requires “Answered” or “Resolved” statuses for user queries, the possibilities are endless.
Create Custom Post Status in WordPress
If you want to create your own post status without using the plugin, you need to add the following code into functions.php of your child theme which adds “In Writing” post status on your post:
// 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 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>
$(document).ready(function(){
$("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>");
});
</script>
';
}
}
add_action('admin_footer', 'display_custom_post_status_option');
Custom post status in wordpress empower WordPress users to personalize their content management experience and align it with their unique needs. By creating custom post status in wordpress, you can enhance workflow management, improve organization, and tailor your content management process to your specific niche.
Whether you’re a developer or a non-technical user, WordPress offers various options to implement custom post statuses, allowing you to unleash your creativity and unlock the full potential of your website.
You can then see this custom post status in wordpress admin post editing page. That’s it 🙂