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') %}
  • in Craft 4.x you would write it the following way: .section(['not', 'this','that','someOther'])
    – outline4
    Commented Jul 4, 2023 at 17:00

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.