Created
July 22, 2017 13:56
-
-
Save sabrina-zeidan/e7cae401a1cd88d902f28d28431fbd92 to your computer and use it in GitHub Desktop.
Bulk delete all custom posts [Wordpress]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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