Articles of post status

Programmatically change post visibility on save_post action return a 500

I’m trying to change the post visibility for my custom post type. On the edit.php screen the user can use a custom field to set the post type to normal or extended. That field shall work as abstraction for the post_status. However, running the following code inside the save_post action terminates as 500 Internal Server […]

What function publishes a post when you click the publish button?

I’m trying to track down an issue with a plugin. In vanilla WP when you are on the post edit screen (/wp-admin/post.php) what function is getting called to change the post status from draft to publish? I’ve looked in that post.php and there is nothing that I’m seeing do it. I’m thinking that it may […]

Restrict access to a post once it is tagged as a given status

I am trying to make any post that has been tagged and saved with a certain status non-editable by editor users. I am using a custom plugin that extends the status’ to include subbing, however, at present I am just trying to get the functionality there so am using the publish status. Can anyone see […]

Also show terms that are related to draft and pending posts

Im using wp_dropdown_categories to output terms in dropdown menu but it only shows terms that are related to published posts. I wonder if there’s a way / hack to include terms that are related to pending and draft posts? Codex doesn’t say anything about that, also searching the web didn’t give any results.

Is there a way getting post fields using `transition_post_status`

First I tried fetching post_meta data, and latest, I tried fetching get_post_field() inside a transition_post_status hooked function, like: <?php add_action( ‘transition_post_status’, ‘yes_send_email_notification’, 10, 3 ); function yes_send_email_notification( $new_status, $old_status, $post ) { if( ‘mycpt’ === $post->post_type && ‘new’ === $old_status && ‘pending’ === $new_status ) : $post_id = $post->ID; /** * Generate Dynamic values */ […]

Bulk Update of Custom Post Type Post Status through SQL

The following code updates the post status of standard wordpress posts to ‘Archived’. UPDATE wp_posts SET post_status = ‘Archived’ WHERE post_status != ‘static’; How can I make this only affect custom post types with the slug of ‘cpt_operator’. I know I can do this from Wp-Admin but with over 2,500 posts its a huge task.

Is there a before_save_post hook or something similar

I need to check the value of a post status before is changed during a post update or even bulk update. And then depending on that value, adjust other values of the post Example: Lets say I have a custom post status status-one status-two status-three I have post “A” who’s status is status-one. So when […]

how can i allow users to view their own pending posts in a front-end page

i want to allow users to view their own pending posts in a front end page but when i access the links created for pending post in the database the links doesn’t work until the post is approved If I access the post GUID the one where the status is “publish” the link works, but […]

Auto-generated posts not showing in backend (but being counted!)

I have a custom post type with a custom backend page. I’m creating posts of that type using this code: $postarr = array( “post_type” => “product_settings”, “post_status” => “published”, “post_title” => “$ean $name”, “post_content” => “$ean $name”, // to satisfy WP requirement “meta_input” => array(“ean” => $ean) ); $id = wp_insert_post($postarr); if (!$id) echo “ERR: […]

transition_post_status doesn't work with bulk updates

I have successfully setup an action that executes when a custom post type is moved from “pending” to “publish” status. Everything works as expected when you change the post status individually (press the “Publish” button on the individual post edit page). However, when using the Bulk Actions on the overview page for the custom post […]