Multiple Post Status

How can I assigned a post to multiple post status like it will be in ‘publish’ status and also a custom post status say ‘hide’ post status. This can be achieved by storing a post meta value. You can do stuff on the post based on this meta value. by this publish post count will … Read more

wordpress post status inquery

That is called as Revision in WordPress. Whenever you update your post, the older content of that post is treated as Revision and a new record for revision is inserted in posts table. And we can check our revisions from Revision meta box. More detail : https://codex.wordpress.org/Revisions For – How to solve it to make … Read more

Workflow for attachments in WordPress

Here is how I realized a simple media workflow. Security checking and sanitizing is up to everyone. Based on WordPress version: 4.9.8 Create Attachment Post | Handle Media if (!empty($_FILES) && isset($_POST[‘postid’])) { media_handle_upload(“attachments”, $_POST[‘postid’]); } Post status pending is not possible for attachments when using media_handle_upload. For this case a filter needs to be … Read more

Force Custom Post Type Status to ‘Future’ on first Save or Publish

wp_insert_post_data filters post data just before it is inserted into the database. Documentation add_filter(‘wp_insert_post_data’, ‘schedule_post_on_publish’, ’99’); function schedule_post_on_publish($data) { $post_type = “event”; // Replace event with exact slug of your custom post type if ( $data[‘post_type’] == $post_type AND $data[‘post_status’] == ‘publish’ ) { $data[‘post_status’] = ‘future’; } return $data; } This may help.

Function to change post status IF current user and post author are the same

I was unable to find any action called wp_update_post. Are you sure it’s a valid one? Lets try the hook publish_post. add_action(‘publish_post’, ‘check_user_publish’, 10, 2); function check_user_publish ($post_id, $post) { $user_id = get_current_user_id(); if ($user_id != $post->post_author) return; $query = array( ‘ID’ => $post_id, ‘post_status’ => ‘draft’, ); wp_update_post( $query, true ); }} code not … Read more