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?

1 Answer 1


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, 2019 at 10:33
  • Came across this trying to pass a list of entry ids from an entry field into a Sprig component with pagination (Craft v4.4.x). {% set entryQuery = craft.entries().id(ids).fixedOrder(true).limit(limit) %} 👍
    – Jeff Irwin
    May 2, 2023 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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