<div class="letter-list">
<?php
$posts = get_posts(
array(
'post_type' => 'logos',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
)
);
$alphas = range('A', 'Z');
$letter_keyed_posts = array();
if ( $posts ) {
foreach ( $posts as $post ) {
$first_letter = strtoupper( substr( $post->post_title, 0, 1 ) );
if ( ! array_key_exists( $first_letter, $letter_keyed_posts ) ) {
$letter_keyed_posts[ $first_letter ] = array();
}
$letter_keyed_posts[ $first_letter ][] = $post;
}
}
foreach ($letter_keyed_posts as $key => $value) {
?>
<ul>
<div class="letter"><?php echo $key; ?></div>
<?php foreach ($value as $val) {
?>
<li><a href="<?php echo get_permalink( $val->ID ); ?>"><?php echo $val->post_title; ?></a></li>
<?php
} ?>
</ul>
<?php
}
?>
</div>