Site icon Hip-Hop Website Design and Development

custom post type category count shortcode

I’d like to create a shortcode that would display the post count for a specific category within a custom post type. I’ve been trying to alter the code below but need some help. Could anyone let me know how to tweak so that the shortcode is for a specific custom post type.

// Add Shortcode to show posts count inside a category
function category_post_count( $atts ) {

    $atts = shortcode_atts( array(
        'category' => null
    ), $atts );

    // get the category by slug.
    $term = get_term_by( 'slug', $atts['category'], 'category');

    return ( isset( $term->count ) ) ? $term->count : 0;
}
add_shortcode( 'category_post_count', 'category_post_count' );

Thanks in advance!