Splitting posts by month, but sorting by day
This is confusing me a bit, as it seems such an obvious thing to want to do but I can’t see any suggestions / solutions.
I have a series of posts which I want to break up by month. That’s easy enough, I use
$event_query = new WP_Query( array( 'monthnum' => $eventmonth, 'post_type' => array( 'people', 'families'), 'order' => 'ASC', 'orderby' => 'date', 'posts_per_page' => -1 ) ); while ( $event_query->have_posts() ) : $event_query->the_post(); // Do stuff endwhile;
(I’m using this in a shortcode and passing the month number as $eventmonth).
Trouble is, of course, that returns all the posts sorted by year, when I want them sorted by the day of the month. I want 1 Jan 2013, 1 Jan 2012, 2 Jan 1973, 3 Jan 1999, whereas I get 2 Jan 1973, 3 Jan 1999, 1 Jan 2012, 1 Jan 2013.
What I can’t work out is how to to sort my query results by the order of the day of the month. I’m guessing I need to break out the day using the_time (or the_date) but beyond that, I’m lost.
All help gratefully received!
- The topic ‘Splitting posts by month, but sorting by day’ is closed to new replies.