1

I have this code:

<?php
$letter=' '; 
query_posts( array (  'orderby' => 'title', 'order' => 'ASC' ) );
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<ul>
    <?php 
    $title=get_the_title(); 
    $initial=strtoupper(substr($title,0,1));
    if($initial!=$letter)
      {
      echo "</ul><h4>$initial : </h4><ul>";
      $letter=$initial;
      }
    echo '<li>'.$title.'</li>';
    ?>
</ul>
<?php endwhile; endif; wp_reset_query(); ?>

I show the results by groups, in this way:

**&**
'title
"othertitle

**1**
1555555555
1666666666

**2**
2111111111
2555555555

**A**
abbbbbbbbb
annnnnnnnn

**B**
blllllllll
bhhhhhhhhh

But I want a group in this way:

**0>9**
1555555555
1666666666
2111111111
2555555555

**A**
abbbbbbbbb
annnnnnnnn

**B**
blllllllll
bhhhhhhhhh

**O**
othertitle

**T**
title

So I'd like to show:

  • results grouped in letters (A>Z) in different group (ex: group A, group B, group C,...)

  • results grouped in numbers (0>9) in the same group

  • delete the first character from the title with the initial apostrophe (') or quote (").

How can I resolve please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.