0

How can you execute a search query, that excludes all entries associated to a specific category?

Many answers say "fetch all the items associated to that category, and then filter them out" - However we have around 2000-4000 entries that we would like to exclude so do not feel this is feasible.

Effectively I want something like...

Entry::find()
->relatedTo([
   'and',
    ['targetElement' => [1,2,3], 'field' => 'category'],
    ['targetElement' => 'not 4', 'field' => 'category'],
])->all();

So find all that are in category 1 or 2 or 3, but make sure they're not in 4.

Thanks

Your Answer

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

Browse other questions tagged or ask your own question.