Viewing 1 replies (of 1 total)
  • You can’t sort posts by category. You can retrieve the categories in alpha order, then for each category, retrieve that category’s posts and display them.

    <?php
    $categories=get_categories('orderby=name&amp;order=ASC');
      foreach($categories as $category) {
          $posts=get_posts('showposts=-1&amp;cat='. $category->term_id);
          if ($posts) {
            echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
            foreach($posts as $post) {
              setup_postdata($post); ?>
              <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
              <?php
            } // foreach($posts
          } // if ($posts
        } // foreach($categories
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Arranging Post Order in Category’ is closed to new replies.