Multiple sort orders within one loop
-
Interesting (at least I think so) problem.
I have a custom post type (sermons) with a custom taxonomy (sermon_series). I also have a custom field (sermon date) that gives the date the “sermon” was preached (not posted). The archive page for the post type has the posts ordered by the custom field “sermon date.” This also happens to group them by “sermon series” as series are normally taught consecutively. This is in DESC order. However, I want to provide the sermons in DESC order by sermon date in the sermon series, but in ASC order within their sermon series. This is how they are now)
Sermon series 2 (Sermon 4), Sermon Series 2 (Sermon 3), Sermon Series 2 (Sermon 2), Sermon Series 2(Sermon 1), Sermons Series 1 (Sermon3) etc…
I want them to be :
Sermon Series 2 (Sermon 1), Sermon Series 2 (Sermon 2), Sermon Series 2 (Sermon 3), Sermon Series 2(Sermon 4), Sermons Series 1 (Sermon 1) etc…So one loop that is ASC within another loop that is DESC. Here is my current code:
<?php query_posts(array( 'post_type' => 'sermons', 'orderby' => 'meta_value', 'meta_key' => 'ct_Sermon_Dat_datepicker_f5f2', 'paged' => $paged, 'order' => 'DESC' )); if(have_posts()): while(have_posts()): the_post(); ?>
Any help would be appreciated!
- The topic ‘Multiple sort orders within one loop’ is closed to new replies.