Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Last active September 13, 2021 22:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sabrina-zeidan/449c10b84b2fde7a0d0d08cd5592d297 to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/449c10b84b2fde7a0d0d08cd5592d297 to your computer and use it in GitHub Desktop.
Bulk delete all posts [Wordpress]
function bulk_delete_posts(){
$args = array( 'post_type' =>'post', 'posts_per_page' => -1, 'post_status' => 'any', 'fields' =>'ids');
$books = get_posts( $args );
foreach ($posts as $post) {
wp_delete_post( $post, true);
}
}
add_action( 'wp_head', 'bulk_delete_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment