Last active
September 13, 2021 22:27
-
-
Save sabrina-zeidan/449c10b84b2fde7a0d0d08cd5592d297 to your computer and use it in GitHub Desktop.
Bulk delete all 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_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