How To Add Custom Post Status In WordPress

Plugins-Folder
Best Practices For Dealing With WordPress Plugin Conflicts
5. novembra 2016.
Best Mobile Apps to Manage Your WordPress Site
Best Mobile Apps to Manage Your WordPress Site 2016.
8. novembra 2016.
custom post status

Are your post drafts getting out of control?

If you have a complicated, multi-step workflow to your blog, or you manage multiple authors, saving all your posts as drafts until they publish just isn’t going to cut it.

In reality, posts drafts go through many phases before they’re published, including:

  • Research
  • Writing
  • Editing
  • Formatting
  • Enhancing with multimedia

If you want to stay organized and make your workflow more efficient, especially if you’re working with a team, it would help to be able to change each post’s status depending on where it is in your process – and you can do that with custom post status.

In this post, we’ll go over how you can create your own custom post status, both manually and with a dedicated plugin.

But, if you’re not comfortable with editing code – definitely go for the dedicated plugin option.

Why create custom post status?

Default post statuses in WordPress include:

  • 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.

When you’re creating a post, you can only make it a Draft, Pending, Scheduled, or Post.

For many bloggers, these statuses will be enough… but if you have a more specific or complicated workflow for your blog, you may need to customize these.

By creating custom statuses, you can more easily keep track of the state of each blog post, and what needs to be done before it’s ready to publish. Instead of keeping notes and to-do lists scattered across your email and other applications, you can see understand the status of your blog at a glance right from your WordPress dashboard.

For example, you might want to add custom statuses for:

  • Pitch: Ideas for posts pitched to you by a writer, that need to be approved or edited before the post is drafted
  • Needs Work: Posts that are sent back to the writer to incorporate requested edits
  • Waiting for Images: Posts that are finished being written, but need images created or added to them
  • Waiting for Edit: Posts that need a final review by an editor before publication

How to manually add custom post status using functions.php

Warning: Before making any changes to your functions.php file, be sure to back it up first! Even the slightest error in your functions.php file — such as an extra bracket or missing comma — can bring your entire site down. Having a backup ready to restore will save you from losing visitors to excessive downtime.

WordPress does have a built-in function for adding custom post status, but it’s not an ideal solution.

Unfortunately, because of the way the WordPress core is designed, the process for adding custom post status to your dashboard is a little more complicated than it should be: You can create a custom post status in functions.php using the “register_post_status” function, but it won’t actually show up in the drop-down menus in the admin panel when you’re creating or editing a post.

There’s actually been an open ticket about this issue… for the past 6 years. Maybe someday it will be fixed!

But, until then, there are ways to get around that if you’re determined.

Here’s an example of how to use the “register_post_status” function to register a custom post status:



Code  
function my_custom_post_status(){
 
 
 
 
 
  register_post_status( 'pitch', array(
 
 
 
 
 
    'label' => _x( 'Pitch', 'post' ),
 
 
 
 
 
    'public' => false,
 
 
 
 
 
    'exclude_from_search' => true,
 
 
 
 
 
    'show_in_admin_all_list' => true,
 
 
 
 
 
    'show_in_admin_status_list' => true,
 
 
 
 
 
    'label_count' => _n_noop( Pitch <span class="count">(%s)', Pitches <span class="count">(%s)' ),
 
 
 
 
 
  ) );
 
 
 
 
 
}
 
 
 
 
 
 
 
 
 
 
 
add_action( 'init', 'my_custom_post_status' );

In the above example, a new post status called “pitch” is being added.

Here are the relevant parameters:

  • label: A descriptive name for the post status.
  • public: Whether posts of this status should be shown in the front end of the site. (That is, whether they’re published or not.)
  • exclude_from_search: Whether to exclude posts with this post status from search results.
  • show_in_admin_all_list: Whether to include posts in the edit listing for their post type.
  • show_in_admin_status_list: Whether it shows in the list of statuses with post counts at the top of the edit listings, e.g. All (12) , Published (9) , My Custom Status (2)
  • label_count: The text to display on the admin screen. The first is singular, and the second if plural.

Now, this code will register your new custom status behind the scenes… but you won’t be able to apply the new status to any posts from the dropdown menu while you’re editing them.

In order to get it to show up in your edit screen dropdown, you can use the code from James Collings, under the second section, “Adding custom post status to WordPress status dropdown.” The code uses jQuery to add a custom post status to the admin panel on the edit post page.

Add custom post status with the plugin WordPress Post Planner

Editors note: when we first came up for the idea of this post a month or so ago, it was because the free Edit Flow plugin that we previously used for managing custom post status hadn’t been updated in a long time. We had some issues with it and wanted to share other options. But, now Edit Flow has been updated so it should work fine, although we haven’t tested it yet – click here to learn more about Edit Flow.

Looking for an easier method, with a few extra features built in?

Check out WordPress Post Planner, a plugin available from CodeCanyon for just $25.

It has a lot of features that help you to organize your blog’s workflow. You can use it to:

  • Assign posts to specific users
  • Assign due dates
  • Create a standard checklist for every post
  • Have editorial comments on posts
  • Add and insert reference links for each post
  • Set a dashboard widget and front-end widget to display upcoming posts and other data

And, of course, you can set and assign your own custom post status, including setting a color for each status for the dashboard widget.

To set up your custom post status, install the plugin as usual, and navigate to the new menu option Settings > Post Planner > Statuses. Here you can create your own custom statuses.

Conclusion

WordPress out of the box has good post statuses that are sufficient for most users, but the most organized bloggers need more flexibility in order to be at their most efficient. If you need custom post status, check out the plugin above, or try to create your own using the code above.

Note:

I respect copyrights.
The original author of this post is: KeriLynn Engel
The basis of this post I took up from: WP Superstars

Ostavite odgovor

Vaša adresa e-pošte neće biti objavljena. Neophodna polja su označena *