Change scheduled posts to published

Ok… so when trying to turn a future post to a published post you need to remember to set “post_date_gmt” and not only the “post_date” to the desired date. Thanks to @gmazzap which helped me get there… here is a working example based on my question /* CHANGE PENDING POSTS TO PUBLISHED POSTS */ function … Read more

Changing post status

That code is part of something bigger, as there are many places where the custom post_status needs to be inserted. There are two interesting discussions here at WPSE and both point to the use of this plugin: Edit Flow. Is it possible to have more “levels” of draft/published statuses? Add a new post status in … Read more

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

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

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!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)