have_posts()){ while($query->have_posts()){ $query->the_post(); wp_delete_post(get_the_ID()); } wp_reset_query(); }