Site icon Hip-Hop Website Design and Development

Display tags cloud from a specific category ID with a shortcode

I’m trying to display some tags cloud in different locations of my WordPress. I’m using a shortcode but I’m looking for a way to display only the tags from a specific category ID by adding this ID right in the shortcode like:

 [tagscloud cat_id='2']

I made this but I’m stuck because I don’t know how to filter/apply (not sure about the right term) the cat_id.

function wp_tags_cloud_shortcode($atts) {

    extract(shortcode_atts(array(
        'cat_id' => ''
    ), $atts));

    $content = wp_tag_cloud( array( 
    'echo'      => false,
    'smallest'  => 10,
    'largest'   => 10,
    'unit'      => 'px',
    'number'    => 0,
    'format'    => 'flat',
    'orderby'   => 'count' ) 
    );
    return $content;    
}
add_shortcode( 'tagscloud', 'wp_tags_cloud_shortcode' );

I’m a beginner with php so any help will be much appreciate 🙂