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

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

WP_Post_List_Table::get_views – Have post counts account for filters?

You might want to remove those counts and replace them with your own. function insert_post_counts($views){ //Run your query to count posts //use wp_cache_set and wp_cache_get to optimize performance $edit_url = admin_url( ‘edit.php’ ); $views[‘all’] = ‘All <a href=”‘.$edit_url.'”>(‘.$all_count.’)</a>’; $views[‘publish’] = ‘Published <a href=”‘.$edit_url.’?post_status=publish”>(‘.$publish_count.’)</a>’; $views[‘draft’] = ‘Draft <a href=”‘.$edit_url.’?post_status=draft”>(‘.$draft_count.’)</a>’; $views[‘trash’] = ‘Trash <a href=”‘.$edit_url.’?post_status=trash”>(‘.$draft_count.’)</a>’; return $views; … Read more

How can I run custom function when post status is changed?

See this Codex page. In general the hook is {old_status}_to_{new_status}. (Untested) but in your case, the hook would be pending_to_draft: add_action(‘pending_to_draft’,’wpse45803_pending_to_draft’); function wpse45803_pending_to_draft($post){ //Do something } You might want to look up the wp_transition_post_status function. You could also use the hook: transition_post_status add_action(‘transition_post_status’,’wpse45803_transition_post_status’,10,3); function wpse45803_transition_post_status($new_status,$old_status,$post){ //Do something }

Changing post status in one click

You can create your custom button in a function and hook it into post_submitbox_misc_actions and this will add it right above the publish button. To change the status use wp_update_post in an Ajax function. Give it a try and post back with your code if you run into any problems. UPDATE: add_action(‘post_submitbox_misc_actions’, ‘send_for_correction_button’); function send_for_correction_button() … Read more

register_post_status and show_in_admin_all_list

This solves my problem: register_post_status(‘my_custom_post_status’, array( ‘label’ => __(‘The Label’, ‘domain’), ‘public’ => !is_admin(), ‘exclude_from_search’ => true, ‘show_in_admin_all_list’ => false, ‘label_count’ => //blablabla )); !is_admin() makes the status only public on the frontpage. If you find a better solution please post it here!

Why doesn’t wp_update_post() update the post_status field?

Answer couldn’t be simpler. As pointed out by Otto at the wp-hackers list, problem was me not setting post_date_gmt when using wp_update_post(). Final code looks like this: if ( $post_date < strtotime( “tomorrow” ) ) { $status=”publish”; $newpostdata[‘post_status’] = $status; $newpostdata[‘post_date’] = date( ‘Y-m-d H:i:s’, $post_date ); // Also pass ‘post_date_gmt’ so that WP plays … Read more

how to assign a status/mark to post?

You can create your own meta box with a checkbox and only select posts that where checked: Add metabox code /* Define the custom box */ add_action( ‘add_meta_boxes’, ‘my_slider_add_custom_box’ ); /* Do something with the data entered */ add_action( ‘save_post’, ‘my_slider_save_postdata’ ); /* Adds a box to the main column on the Post and Page … Read more