Creating a “glossary” of WordPress posts of a specific post type

Declare a $previous_letter variable, and at the end of the foreach give it the value of the current $glossary_letter. Before of show the $glossary_letter make an if condition. If $glossary_letter is different to the $previous_letter then show it.

$previous_letter = null;

foreach ( $postslist as $post ) :

  setup_postdata( $post );

  $glossary_title = get_post_custom_values($key = 'glossary_title');
  $glossary_description = get_post_custom_values($key = 'glossary_description');
  $glossary_letter = substr($glossary_title[0], 0, 1);

  ?>

  if ( $glossary_letter !== $previous_letter ):
      <h3><?php echo $glossary_letter; ?></h3>
  endif;

    <p><a href="https://wordpress.stackexchange.com/questions/286889/<?php the_permalink(); ?>"><?php echo $glossary_title[0]; ?></a>: <?php echo $glossary_description[0]; ?></p>
  <?php

$previous_letter = $glossary_letter;
endforeach;