Try this one:
Just add the function in your theme functions file and then in your (search) template, add echo get_query_terms_list();
to display the terms list. But do take note, this is intended only for the current search results, i.e. on the same page.
function get_query_terms_list( $taxonomy = 'post_tag', $sep = ', ' ) {
$list = array();
foreach ( $GLOBALS['wp_query']->posts as $post ) {
if ( is_array( $terms = get_the_terms( $post, $taxonomy ) ) ) {
foreach ( $terms as $term ) {
// Set the term's initial count.
if ( ! isset( $list[ $term->term_id ] ) ) {
$list[ $term->term_id ] = 0;
}
// And then increment it for each post.
$list[ $term->term_id ]++;
}
}
}
// Sort by the count, highest to lowest.
arsort( $list );
$links = array();
foreach ( $list as $term_id => $count ) {
$term = get_term( $term_id );
$link = get_term_link( $term );
if ( ! is_wp_error( $link ) ) {
$links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' .
$term->name . " (<b>$count</b>)" . '</a>';
}
}
return implode( $sep, $links );
}