Needing a snippet for listing category specific tags

I finally found an answer. It didn’t work the first few times I used it, but after reworking some HTML and with a better grasp of what I’m doing, I was able to put this together. This was from an answer here on W.SE but I can’t locate it anymore:

<?php
    $custom_query = new WP_Query( array( 'cat' => get_query_var('cat') ) );

    if ( $custom_query->have_posts() ) :
       while ( $custom_query->have_posts() ) : $custom_query->the_post();
          $posttags = get_the_tags();
          if ( $posttags ) {
             foreach( $posttags as $tag ) {
                $all_tags[] = $tag->term_id;
             }
           }
        endwhile;
    endif;

    $tags_arr = array_unique($all_tags); $tags_str = implode(",", $tags_arr);

    $args = array(
        'smallest'  => 14,      'largest'    => 14,
        'unit'      => 'px',    'number'     => 0,
        'format'    => 'list',  'show_count' => 1,
        'include'   => $tags_str
    );
    wp_tag_cloud($args);
?>

What I’m able to gather from this is that we need to use a seperate loop and invoke a new WP_Query.

This query is using an array to extract the category that was clicked. Once that happens, the tags listed under that category are gathered up and laid out in a tag cloud.

Then we’re reworking the tag cloud to display in a list instead of the typical cloud format. I added show_count => 1 to show how many times a particular tag was used.

I will post the page on my website that I used it so you can see it in action. Of course, I won’t do that until it’s done 🙂