Title: Adding second orderby makes the loop disappear
Last modified: January 10, 2021

---

# Adding second orderby makes the loop disappear

 *  [philipt18](https://wordpress.org/support/users/philipt18/)
 * (@philipt18)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/adding-second-orderby-makes-the-loop-disappear/)
 * I have a loop that I’m trying to order by date, except many of the items are 
   historical, so the dates posted don’t match the date of the item. I have a year
   field that is displayed, so I instead sort by that year field. The problem is
   that when there are multiple items with the same year, the order is messed up.
   So I wanted to add a second orderby field to sort within the year by the posting
   date. When I do that, however, the loop just disappears. Here’s the first loop:
 * `[loop type=award orderby=field_num key=year order=DESC]`
 * and the second one that disappears:
 * `[loop type=award orderby=field_num key=year order=DESC orderby_2=date order_2
   =DESC]`
 * Any idea why the second one simply vanishes? Thanks.

Viewing 1 replies (of 1 total)

 *  [polarracing](https://wordpress.org/support/users/polarracing/)
 * (@polarracing)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/adding-second-orderby-makes-the-loop-disappear/#post-13892056)
 * You can achieve this by nesting loops.
 * First run loop one with orderby=field_num then run a second one looping the results.
 * The first loop gives you all items with the proper year and the second one sorts
   within the result for the right order of your items.
 *     ```
       [loop type=award orderby=field_num key=year order=DESC]
       [-loop type=award orderby=date order=DESC]
       YOUR RESULT HERE
       [/-loop]
       [/loop]
       ```
   
    -  This reply was modified 5 years, 4 months ago by [polarracing](https://wordpress.org/support/users/polarracing/).

Viewing 1 replies (of 1 total)

The topic ‘Adding second orderby makes the loop disappear’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

## Tags

 * [orderby](https://wordpress.org/support/topic-tag/orderby/)

 * 1 reply
 * 2 participants
 * Last reply from: [polarracing](https://wordpress.org/support/users/polarracing/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/adding-second-orderby-makes-the-loop-disappear/#post-13892056)
 * Status: not resolved