I'm trying to build a search function that excludes results from certain sections all together. This is the code I was trying to use.

{% set entries = craft.entries.search(query).section('not testimonials, not authors').id('not 2').order('score') %}

When I use just one section, it works fine:

{% set entries = craft.entries.search(query).section('not authors').id('not 2').order('score') %}

Any thoughts on how I could construct this query?

1 Answer 1


The trick is to add and once before the first not

{% set entries = craft.entries.search(query).section('and, not this, not that') %}

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.