<?php
$query_string = '
SELECT *,name FROM '.$wpdb->prefix.'term_taxonomy
JOIN '.$wpdb->prefix.'terms
ON '.$wpdb->prefix.'term_taxonomy.term_id = '.$wpdb->prefix.'terms.term_id
WHERE '.$wpdb->prefix.'term_taxonomy.taxonomy = "post_tag"
ORDER by '.$wpdb->prefix.'terms.name ASC
';
$post_tags = $wpdb->get_results($query_string);
?>
<div id="a" class="abc_tags">
<ul>
<?php
foreach($post_tags as $key => $tag) {
$newletter = substr($tag->name, 0, 1);
if($newletter !== $letter && $key != 0) { ?>
</ul>
</div>
<div id="<?php echo strtolower($newletter); ?>" class="abc_tags">
<ul>
<?php } $letter = substr($tag->name, 0, 1); ?>
<li><a href="<?php echo get_tag_link($tag->term_id); ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $tag->name ); ?>"><?php echo $tag->name.' ('.$tag->count.')';?></a></li>
<?php
}
?>
</ul>
</div>