Stole some code from the tdo-tag-fixes plugin:
<?php
//get all posts in a given category
//then store a count of posts by tag in array
//sort array descending by number of posts
//display just the number of tags needed
$tag_counts = array();
$max_tags = 15;
$cat_id = get_cat_ID('Uncategorized1');
$args=array(
'cat' => $cat_id,
'post_type' => 'post',
'post_status' => 'publish',
'nopaging' => true,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if($my_query->have_posts()) {
$posts = $my_query->get_posts();
foreach($posts as $post) {
$post_tags = wp_get_post_tags($post->ID);
if(!empty($post_tags)) {
foreach($post_tags as $post_tag) {
$tag_counts[$post_tag->term_id]+= 1;
}
}
}
}
wp_reset_query();
if ($tag_counts) {
arsort($tag_counts); //sort array in reverse order by number of posts
foreach($tag_counts as $key => $tag_count) {
$count++;
if ( $count <= $max_tags) {
$term = get_term_by('id',$key, 'post_tag');
echo '<p>' . '<a href="' . get_term_link( $term, 'post_tag' ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> has ' . $tag_count . ' post(s). </p> ';
}
}
}
?>