Skip to content

Instantly share code, notes, and snippets.

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