I'd like to get a certain set of entries in a specific order, but the element query comes back ordered by the default 'postDate desc'

{% set ids = ['4213','3200','4204','4212']

{% set orderedEntries = craft.entries().id(ids).order('id').all() %}

{{ dump(orderedEntries.ids) }} <- not the same order as the array!

It feels like there should be a relatively simple way of doing this in craft/twig, am I missing something? Or should I just resort to SuperSort?


You can do this by adding .fixedOrder(true) to your query:

{% set ids = ['4213','3200','4204','4212'].fixedOrder(true) %}


  • Thanks, how did i miss that?! Apr 15 '19 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.