Group results by letter

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php while ( have_posts() ) : the_post(); ?>
<?php
$letter = strtoupper( substr( get_the_title(), 0, 1 ) );
if ( empty( $last_letter ) || $letter != $last_letter ) {
echo ‘<h3 class=”letter”>’ . $letter . ‘</h3>’;
}
$last_letter = $letter;
?>
<div><strong><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></strong><?php the_excerpt(); ?></div>
<?php endwhile; ?>
{{/gist}}