Being a comprehensive content management system, WordPress allows users to choose from a number of statuses to assign to their posts. The post’s status determines how WordPress handles that post on the back-end. By default, there are eight different post statuses you can assign to posts, including:
- Draft. Incomplete posts viewable by anyone who has correct permission.
- Pending. Posts that have been completed but are awaiting review from someone with publish capability to publish them.
- Publish. Viewable to everyone from the front-end.
- Future. These posts are set to be published in a future date.
- Private. Posts set as private are only viewable by administrators.
- Trash. These posts have been deleted (not permanently deleted) but are recoverable.
- Auto-Draft. Auto-drafts are post revisions that WordPress saves automatically while you’re writing them.
- Inherit. These are used with child posts to determine their actual status from the parent post associated with them.
However, when you find your post drafts getting out of control, it may be time to add custom post status types to simplify your multi-step editorial workflow. Since WordPress doesn’t allow you to integrate additional post statuses by default, we’ve put together a snippet generator that helps you register custom post statuses for your admin panel. Before we begin, let’s take a look at what post statuses are and why you may need a custom post status or two.
What Is a Custom Post Status and Do I Need It?
WordPress comes with a set of pre-defined post statuses out of the box. Although they may be enough for some users, others may want to fine-tune their site’s editorial workflow to ensure maximum productivity. Custom post statuses enable users to stay organized and make their workflow more efficient by introducing a new categorization for posts.
If you have an entire team working on publishing content, a custom post status may be used to better identify where a particular post is in the editorial process. For instance, if your editorial process starts out with topic pitches and then moves onto post outlines, you may want to create two custom post statuses called Pitch and Outline.
How Do I Use This WordPress Post Status Snippet Generator Tool?
Our WordPress post status code snippet generator tool is designed to help developers improve WordPress’ default editorial workflow by breaking it down into client-tailored stages. All you have to do is enter the required fields into the text boxes and the tool will generate theme-specific custom code for you.
Let’s take a look at the individual fields one by one:
-
General Tab
- Theme Slug: Enter your theme’s slug into this text field in all lowercase letters, numbers and/or underscores. This value will be used to prefix functions and variables that would otherwise be incompatible with the WordPress core or any installed themes or plugins. Typically, this is the same string as the text domain with underscores in place of hyphens.
- Text Domain: The text domain works as a unique key that will be used to identify any translatable strings in your theme or plugin. It should be the same as your theme’s name in lowercase with spaces replaced by hyphens – in other words, it should match the theme’s directory name in the root folder.
-
Status Tab
- Post Status Slug: This value represents the custom post status’s slug. It should be in all lowercase letters, numbers, and/or underscores. The post status slug can be up to 20 characters long and will be used to prefix functions and variables to avoid any conflict with the WordPress core or plugins.
- Singular Label: Enter the singular label for your custom defined post status here. The label you choose should be descriptive since it will be marked for translation. For instance, if you want to create a post status for receiving pitches, then you could label it Pitch.
- Plural Label: Enter the plural label for the post status here. For instance, if your post status is Pitch, the plural label for it would be Pitches.
-
Settings Tab
- exclude_from_search: Enabling this option will exclude all posts with this post status from the search results. By default, the box is unticked – that is to say, the default value is set to false.
- public: Setting the public argument to true (i.e. checking this option) means that all posts with this post status will be shown on the front-end of the site. If you want everyone to be able to view the post, tick the public box. By default, this value is set to false.
- internal: Enabling this option limits the posts to the back-end only. This means that only users with access to the admin panel will be able to view the post. By default, this value is set to false.
- protected: By enabling this option, it means that only users with permission to edit the post are able to view it.
- private: The private argument defines whether all of the posts with this post status should be accessible only by their URLs. By default, this value is set to false.
- publicly_queryable: Enabling this option allows queries to be performed on the front-end as part of a parse_request().
- show_in_admin_all_list: This argument lets you decide whether or not to include all posts with this post status in the edit listing for their post type. By default, this value is set to true.
- show_in_admin_status_list: Enabling this option means that all posts with this post status will be visible in the list of statuses with the post count at the top of the edit listings. For instance, it may look something like this: All (10), Published (3), Draft (1), Pitch (6). By default, this value is set to false.
-
Code Tab
- Once you’ve enabled all of the options you’d like, navigate to the Code tab. You’ll find the Register Custom Status text area populated with custom code snippets for adding a post status to your WordPress site.
How Do I Add the Code Snippets to My Website?
The fastest way to add the generated code snippets to your site is by pasting them directly into your current theme’s functions.php file. You can edit it directly by heading over to Appearance > Editor from the admin panel.
Alternatively, you can download the theme’s functions.php file to your desktop via an FTP client. Next, open it up in a text editor and paste the code at the bottom of the file. Hit the Save button and re-upload it to your theme’s directory. Once you’re done, the newly added custom post status will be available for use.
Note: The function should not be called before the ‘init’ action.
Conclusion
Improving your site’s editorial workflow by using custom post statuses is a great way to keep things organized. Hopefully, this code snippet generator will save you some time and effort from having to code custom post statuses by hand.
Do you have any questions about the Register Post Status code generator tool? Let us know in the comments section below!
Miriam
August 9, 2017 at 10:48 pmHello,
I did everything as required, but the post status does not show up – any idea what I did wrong?
sheamedia
August 21, 2017 at 12:12 pmHi Miriam, Can you post your code snippet so I can take a look?