$asrfwoo_cpt, 'numberposts' => -1, 'post_status' => 'any', ) ); // Delete each post foreach ( $posts as $post ) { wp_delete_post( $post->ID, true ); // true for force delete } } // Flush rewrite rules global $wp_rewrite; $wp_rewrite->flush_rules(); // delete cache wp_cache_flush();