posts as p WHERE p.post_type='glossar' AND p.post_status='publish' GROUP BY SUBSTRING(p.post_title,1,1) ORDER BY SUBSTRING(p.post_title,1,1) ASC"; $index = $wpdb->get_results($query); echo''; ?>
posts as p WHERE p.post_type='glossar' AND p.post_status='publish' GROUP BY SUBSTRING(p.post_title,1,1) ORDER BY SUBSTRING(p.post_title,1,1) ASC"; $index = $wpdb->get_results($query); foreach ($index as $idx) { echo '

'.$idx->letter.'


'; echo '
'; //start listbox for each letter # Query to get all Articles within a letter $query = " SELECT p.* FROM $wpdb->posts as p WHERE p.post_type='glossar' AND p.post_status='publish' AND SUBSTRING(p.post_title,1,1) = '".$idx->letter."' ORDER BY p.post_title ASC"; $posts = $wpdb->get_results($query); foreach ($posts as $post) { #echo $post->post_title; // build excerpt by limiting the string to 200 items $string = strip_tags($post->post_content); /*if (strlen($string) > 200) { // shorten string $stringCut = substr($string, 0, 200); // string ends with a full word $string = substr($stringCut, 0, strrpos($stringCut, ' ')); }*/ echo'

'.$post->post_title.'

'.$string.'

';} #echo '
';var_export($post);echo '
';} echo '
'; //end letterlist } } else { # Query to get all Articles within a letter $query = " SELECT p.* FROM $wpdb->posts as p WHERE p.post_type='glossar' AND SUBSTRING(p.post_title,1,1) = '".$currentLetter."' ORDER BY p.post_title ASC"; $posts = $wpdb->get_results($query); echo '

'.$currentLetter.'


« Alle anzeigen
'; echo '
'; //start listbox for each letter foreach ($posts as $post) { #echo $post->post_title; // build excerpt by limiting the string to 200 items $string = strip_tags($post->post_content); if (strlen($string) > 200) { // shorten string $stringCut = substr($string, 0, 200); // string ends with a full word $string = substr($stringCut, 0, strrpos($stringCut, ' ')); } echo'

'.$post->post_title.'

'.$string.'

'; #echo '
';var_export($post);echo '
'; }echo '
'; //end letterlist } ?>