Site icon Hip-Hop Website Design and Development

Delete pubished and unpublished posts with wp_delete_post?

There’s a perform that removes all of the posts from a given put up kind nevertheless it does not take away gadgets that standing is "draft". How would it not catch the draft gadgets too?

   perform remove_all_kba_data(){
        //take away articles
        $articles = get_posts( array( 'post_type' => 'kb_kba', 'posts_per_page' => -1) );
        foreach( $articles as $article ) {
            //delete put up, bypass trash
            wp_delete_post( $article->ID, true);
        }
    }