<p>The trick is to add <code>and</code> once before the first <code>not</code></p>

<pre><code>{% set entries = craft.entries.search(query).section('and, not this, not that') %}
</code></pre>

CC BY-SA 4.0
2023-07-04T17:00:38.000Z
in Craft 4.x you would write it the following way: `.section(['not', 'this','that','someOther'])`
outline4
CC BY-SA 3.0
2015-02-19T20:46:08.453Z
2015-02-19T21:23:23.187Z
2015-02-19T21:23:23.187Z
KSPR
<p>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.</p>

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

<p>When I use just one section, it works fine:</p>

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

<p>Any thoughts on how I could construct this query?</p>

<search><sections><entrymodel><queries>
Is it possible to exclude multiple sections from an entry search query?
# Is it possible to exclude multiple sections from an entry search query?

(Asked by: username_0 on 2015-02-19)

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?

**Tags:** search, sections, entrymodel, queries

---

## 1 answers

### Answer by username_1 on 2015-02-19. Score: 29 | Accepted answer

The trick is to add and once before the first not
{% set entries = craft.entries.search(query).section('and, not this, not that') %}

> **Comments:**
> **username_2**: in Craft 4.x you would write it the following way: `.section(['not', 'this','that','someOther'])`  

---

