How to update page status from publish to draft and draft to publish

A faster solution is:

$post = array( 'ID' => $post_id, 'post_status' => $status );
wp_update_post($post);

This way you don’t have to get the post.

Leave a Comment