Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-04T17:00:38.000Z
Answers.Text: in Craft 4.x you would write it the following way: `.section(['not', 'this','that','someOther'])`
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-19T20:46:08.453Z
Answers.LastActivityDate: 2015-02-19T21:23:23.187Z
Answers.LastEditDate: 2015-02-19T21:23:23.187Z
Answers.UserDisplayName: KSPR
Body: <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>
  
Tags: <search><sections><entrymodel><queries>
Title: Is it possible to exclude multiple sections from an entry search query?
ThreadText: # 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'])`  
  
  ---
  
  