preface: i'm new to craft so may get terminology incorrect

basic idea: i would like to show entries of a particular channel which have multi-select field values which intersect with another set of values. e.g. given set ['a','c','e'] it would show entries with values such as ['a','b',c'] and ['e'] but not ['b','d'].

what i have done so far:

my basic ElementCriteriaModel for entries in the past is defined:

{% set results = craft.entries({
    section: ['mysection'],
    when: ' <= ' ~ now,
    order: 'when desc',
}) %}

{% for entry in results %}
.... blah blah do stuff

and what i would like to do is add another criteria on there for the multi-select field. however, from what i am reading and have tried it doesn't seem like that kind of filtering is available. please stop now and prove me wrong if this is not the case!

i was able to filter matching a single option of the multi-select by using:

{% for entry in results if entry.myMultiSelect.contains('a') %}

but was unable to determine syntax to "OR" the results with another contains(). really not much documentation that i could find on that method.

alternately i possibly could use a search, but sounds like that relies on indexes that may get out of date which i would like to avoid. wouldn't be a huge deal, but looking for the "right" answer before i settle on brute forcing it by just looping through the multi-select values inside the loop to check for a match.

1 Answer 1


Not an expert myself, but you can try .contains('OR', 'a', 'b', 'c', 'e')

However, rather than first fetch all entries and then filter them, I would look into using relations when looking them up, so that the initial result only contains the entries you're after.

Have a look at https://craftcms.com/docs/relations to get started, and don't be afraid to ask for help if you can't quite figure them out (I found them a little tricky myself when first attempting to use them).

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.