‘post’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ); $query = new WP_Query($args); $previous_letter = ”; while ($query->have_posts()) { $query->the_post(); $title = get_the_title(); $first_letter = strtoupper(substr($title, 0, 1)); if ($first_letter !== $previous_letter) { echo “

$first_letter

“; $previous_letter = $first_letter; } echo “

$title

“; } wp_reset_postdata(); ?>