Adding custom post status to visibility in publish meta box

I also don’t see a way to edit that form in that location, though there is a hook called post_submitbox_misc_actions near the bottom. I strongly suggest that use that post_submitbox_misc_actions hook or add your own brand new meta_box to the page. There are potentially severe consequences to altering the default meta_boxes, especially that one. However… … Read more

Custom Post Status not showing in Custom Post Type ALL view

You should set the public argument to true. This way the post with ‘inpacking’ or ‘sent’ post_status will also show in total. So your code should be like this: register_post_status( ‘inpacking’, array( ‘label’ => _x( ‘In Packing’, ‘Order packing’ ), ‘public’ => true, ‘exclude_from_search’ => false, ‘show_in_admin_all_list’ => true, ‘show_in_admin_status_list’ => true, ‘label_count’ => _n_noop( … Read more

How to change post status in hook?

You get the full post object as a second parameter on save_post. Use it to change the status just like the following code. add_action( ‘save_post’, ‘wpse_78351_status’, 10, 2 ); function wpse_78351_status( $post_ID, $post ) { remove_filter( current_filter(), __FUNCTION__ ); if ( ‘trash’ !== $post->post_status ) //adjust the condition { $post->post_status=”draft”; // use any post status … Read more

Get a list of ALL Statuses both registered and built-in

This largely depends on where within the boot/request sequence you decide to make an attempt at retrieving statuses and it also depends on whether someone, thing, plugin or theme is doing something, funky, or not but the latter is less likely the case. Useful API functions: get_post_statuses docs | source Retrieves statuses for the built … Read more

Using arbitrary post status without registering it

I’m pretty sure only attachments have post status “enforcement” (“inherit” or “private”), and that’s only inside wp_insert_attachment(). Otherwise there’s no cron action or routine I’m aware of that’ll change stati. I still think you should opt for registering it though. Without any arguments, everything will still behave the way it does currently; they won’t appear … Read more

Creating/editing custom ‘post-state’

_post_states( WP_Post $post ) Parameters #Parameters $post (WP_Post) (Required) Code Reference from wordpress.org (https://developer.wordpress.org/reference/functions/_post_states/) function _post_states($post) { $post_states = array(); if ( isset( $_REQUEST[‘post_status’] ) ) $post_status = $_REQUEST[‘post_status’]; else $post_status=””; if ( !empty($post->post_password) ) $post_states[‘protected’] = __(‘Password protected’); if ( ‘private’ == $post->post_status && ‘private’ != $post_status ) $post_states[‘private’] = __(‘Private’); if ( ‘draft’ … Read more

Custom post status and preview

So actually everything were more simpler, as long as someone (namely me) would have looked how “draft” post status works. Apparently there are a lot of variables that wordpress codex does not reveal / has documented, such as the following: register_post_status(‘purchased’, array( /* ‘label’ => _x( ‘Purchased’, ‘post’ ), ‘public’ => false, ‘exclude_from_search’ => true, … Read more

Restrict a Post Types Post Status

I wonder if you could use something as simple as this: (similar to the suggestion of @ialocin) /** * Use the “Force” on the post status 😉 */ add_action( ‘wp_insert_post_data’, function( $data, $postarr ){ $change_post_status = array( ‘draft’, ‘private’ ); // Edit to your needs if( ‘cpt’ === $data[‘post_type’] && in_array( $data[‘post_status’], $change_post_status, TRUE ) … Read more