Support

Account

Home Forums General Issues Order events by month Reply To: Order events by month

  • This is the way I generally do this. You already have the posts ordered by date. What you need to do is loop through them and when the month changes, add a new heading, so you need to alter the loop a bit.

    This is pretty basic, only showing the concept. It could get more complicated depending on what you want to do between the posts for each month.

    
    $last_month = '';  // empty to start
    while (have_posts()) {
        the_post();
        $this_month = ''; // calculate the month for this post
        if ($this_month != $last_month) {
            echo '<h2>',$this_month,'</h2>';
        }
        $last_month = $this_month;
       // the rest of the output for your post goes here.
    }