Viewing 4 replies - 1 through 4 (of 4 total)
  • Display all posts in alpha order

    <?php
    $args=array(
      'orderby' => 'title',
      'order' => 'ASC',
      'posts_per_page'=>-1,
      'caller_get_posts'=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'Alphabetic index of all ' . count($my_query->posts) . ' posts';
      while ($my_query->have_posts()) : $my_query->the_post();
        $this_char = strtoupper(substr($post->post_title,0,1));
        if ($this_char != $last_char) {
          $last_char = $this_char;
          echo '<h2>'.$last_char.'</h2>';
        } ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    } //if ($my_query)
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Thread Starter khamtv

    (@khamtv)

    Thanks MichealH, please advice me the code need in post/page to appear the posts in groups. For example:
    LIST OF POST
    A:
    post 1
    post 2
    B:
    post 1
    post 2

    Z:
    post 1
    post 2

    Thanks for your advice

    Yep, that’s what that code does.

    This works great, but is there any way to link to a certain letter? For example, if there was an A-Z list and you clicked on C, it would jump down to where the C’s start. Or if you clicked on Z it would take you to the page that Z starts on?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: List category posts] How to group articles in all categories by the A, B, C… groups’ is closed to new replies.