How to display pending posts on the homepage only for editors

I would filter pre_get_posts. function allow_pending_posts_wpse_103938($qry) { if (!is_admin() && current_user_can(‘edit_posts’)) { $qry->set(‘post_status’, array(‘publish’,’pending’)); } } add_action(‘pre_get_posts’,’allow_pending_posts_wpse_103938′); That should show pending posts to your editors for all of your queries on the front end. You can, of course, restrict is more if you’d like. I’d add some code to mark the pending posts so your … Read more

Update status of all posts in a category

I am sure there’s an easier way to accomplish this, but this how I would’ve done. Query all posts with category X and status X Update query results with status Y. $target_category = ‘news’; $change_status_from = ‘draft’; $change_status_to = ‘publish’; $update_query = new WP_Query(array(‘post_status’=>$change_status_from, ‘category_name’=>$target_category, ‘posts_per_page’=>-1)); if($update_query->have_posts()){ while($update_query->have_posts()){ $update_query->the_post(); wp_update_post(array(‘ID’=>$post->ID, ‘post_status’=>$change_status_to)); } } You can … Read more

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

Do action for only switch status for publish_post

You can use the transition_post_status hook, which is fired whenever the status is changed. So to perform an action when the status is changed to publish, you’d do this: function notificationApprove( $new_status, $old_status, $post ) { if ( ‘publish’ === $new_status && ‘publish’ !== $old_status && ‘post’ === $post->post_type ) { // Send mail } … Read more