} elseif (is_page('illustrators')) { $posts = array('paged' => $paged, 'posts_per_page' => '1000', 'post_type' => 'creator', 'orderby' => array('title => ASC'), 'meta_query' => array('relation' => 'AND', array('key' => 'creator_types', 'value' => 'CT2', 'compare' => 'LIKE'))); } elseif (is_page('photographers')) { $posts = array('paged' => $paged, 'posts_per_page' => '1000', 'post_type' => 'creator', 'orderby' => array('title => ASC'), 'meta_query' => array('relation' => 'AND', array('key' => 'creator_types', 'value' => 'CT3', 'compare' => 'LIKE'))); } query_posts($posts); if (have_posts()) { ?> <?php $arrNames = array(); while (have_posts()) { the_post(); array_push($arrNames, array("title" => get_the_title(), "id" => get_the_ID())); } $resSortedNames = $getTadaFunc->getSortedNames($arrNames); for ($i = 0; $i < 26; $i++) { $alphabet = chr(ord('a') + $i); echo '<h2>' . $alphabet . '</h2>'; foreach ($resSortedNames as $key => $value) { if (strtoupper($value["I"]) == strtoupper($alphabet)) { echo '<a href="' . get_permalink($value["id"]) . '">' . $value["F"] . ' ' . $value["L"] . '</a><br>'; } } } ?> <ul class="creatorlist clearfix"> </ul>