Title: Multiple sort orders within one loop
Last modified: August 21, 2016

---

# Multiple sort orders within one loop

 *  Resolved [Matt Pritchett](https://wordpress.org/support/users/mrpritchett/)
 * (@mrpritchett)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/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!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Matt Pritchett](https://wordpress.org/support/users/mrpritchett/)
 * (@mrpritchett)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/multiple-sort-orders-within-one-loop/#post-3893605)
 * Ended up going a different way.

Viewing 1 replies (of 1 total)

The topic ‘Multiple sort orders within one loop’ is closed to new replies.

## Tags

 * [multiple loops](https://wordpress.org/support/topic-tag/multiple-loops/)
 * [order](https://wordpress.org/support/topic-tag/order/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Matt Pritchett](https://wordpress.org/support/users/mrpritchett/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/multiple-sort-orders-within-one-loop/#post-3893605)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
