Skip to content

Instantly share code, notes, and snippets.

@ooooak
Created November 4, 2014 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ooooak/1f471542ee3571284281 to your computer and use it in GitHub Desktop.
Save ooooak/1f471542ee3571284281 to your computer and use it in GitHub Desktop.
wordpress change post status to draft
$posts = get_posts(array(
'post_type' => $post_type,
'posts_per_page' => -1,
'post_status' => 'publish'
));
foreach ($posts as $post){
$post->post_status = 'draft';
echo wp_update_post($post);
echo '<br/>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment