• Hello,

    I have a page where I have a big list of books, which are inserted in the loop through a get_posts() query, but since it is too long list, we would like to split it into smaller sections, preferably by the year published.

    How it is best done? Should I make a separate sub-category for years, and then list it, or set the post-published date and try to group by that?
    How can I make a small list of links on top of the page, which links to these

    My loop is now:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post() ; ?>
    
    <?php
    $myposts = get_posts('posts_per_page=-1&category=3');
    
    $number = 0; // for unifying the looped elements
    
    if($myposts):
    foreach($myposts as $post) :
      setup_postdata($post);
      $number++;
    ?>

    THanks for any suggestion and solution.

    BR,
    g

  • The topic ‘Grouping posts in a category loop by year pages’ is closed to new replies.