WordPress.org

Ready to get started?Download WordPress

Forums

List category posts
How to group articles in all categories by the A, B, C... groups (5 posts)

  1. khamtv
    Member
    Posted 3 years ago #

    Thanks for lovely plugin. I want to group articles in all categories by the A, B, C... groups, is it possible to do?
    Thanks for your advice

    http://wordpress.org/extend/plugins/list-category-posts/

  2. MichaelH
    Member
    Posted 3 years ago #

    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().
    ?>
  3. khamtv
    Member
    Posted 3 years ago #

    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

  4. MichaelH
    Member
    Posted 3 years ago #

    Yep, that's what that code does.

  5. JGrizzLee
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic