• 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)
  • 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 3 years, 10 months ago by polarracing.
Viewing 1 replies (of 1 total)
  • The topic ‘Adding second orderby makes the loop disappear’ is closed to new replies.