4 8 A B C D E F G H I J K L M N O P R S T U V W X Y

<?php

function az_index($post_id) {
    $AZposts = get_posts(array(
        'numberposts'       => -1,
        'post_type'         => 'page',
        'orderby'           => 'title',
        'order'             => 'ASC',
        // 'category'           => $cat
    ));

    $current = "";
    $nav = "";
    $postlist = "";
	echo "<div class='my-glossary'>";
    foreach($AZposts as $AZpost) {
        $postLink = get_permalink( $AZpost->ID );
        $firstletter = strtoupper(substr($AZpost->post_title,0,1));
        if($firstletter != $current) {
            $nav .= "<span class='firstletters'><a href='#$firstletter'> $firstletter </a></span> ";
            $postlist .= "<strong class='is_h3 firstletter' id='$firstletter'> $firstletter </strong>\n";
            $current = $firstletter;
        }
        $postlist .= "<li><a class='postlink' href='".$postLink ."'>" . $AZpost->post_title.  "</a></li>\n";
    }

    print $nav . "<br><br><ul class='glossary-list'>" . $postlist. "</ul>";
	echo "</div>";
}
add_shortcode( 'glossary', 'az_index' );