1

I am trying to filter entries based on multiple field value ranges. For example: All entries where my customField (type: number) is between 0 and 10 OR 20 and 25.

It's straightforward to filter by one range:

{% set results = craft.entries({
  customField: ['and', '>= 0', '< 10']
}) %}

How would I add multiple ranges for the same field to the above query?

1

It's not possible to do both an "and" and an "or" in a single query going though the ElementCriteriaModel.

Here are a few other posts that go into more detail and provide some potential workarounds.

How can I create an ElementCriteriaModel with 'and' and 'or'

How to fetch specific users OR admins with the ElementCriteriaModel?

| improve this answer | |

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.