Display Custom Toxonomy In WordPress and theme Widgets category selection dropdown list

I took a look at the theme’s code. the function covernew_get_terms() function accepts a taxonomy argument, take a look at the source code:

/**
 * Returns all categories.
 *
 * @since CoverNews 1.0.0
 */
if (!function_exists('covernews_get_terms')):
function covernews_get_terms( $category_id = 0, $taxonomy='category', $default="" ){
   #... rest of the code

}
endif;

By default the taxonomy being used is category, so you have to manually specify an array of taxonomies you want included by calling the function this way:

public function form($instance)
{
    $this->form_instance = $instance;

    $categories = covernews_get_terms(0, array('category', 'custom_taxonomy1'));
    #... rest of the code

    }
}

Since you’re working with custom post types, you also have to modify the WP_Query because by default it just retrieves the type ‘post’.

// widget-posts-carousel.php
// $all_posts = covernews_get_posts($number_of_posts, $category); #line 61. Replace with:

$all_posts = new WP_Query(array(
    'post_type' => array('post', 'cptsample'), # set your CPT here.
    'posts_per_page' => absint($number_of_posts),            
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'DESC',
    'tax_query' =>array(
        array(
            'taxonomy' => get_term(intval($category))->taxonomy,
            'field' => 'term_id',
            'terms' => $category
        )
    ) 
));