<p>If anyone lands on this page same as I did, the far far simpler way to do this is just to include the .type() method and combine it with the 'not' word:</p>
<pre><code>{% set results = craft.entries({
  'search': query,
  'type': 'not chapter',
  'order': 'score'
}) %}
</code></pre>

CC BY-SA 4.0
2022-10-21T14:04:14.187Z
This is the correct modern answer to the OP
Adrian
CC BY-SA 4.0
2020-09-04T12:03:51.963Z
2020-09-04T12:03:51.963Z
darylknight
<p>You can target the entry by ID and tell it 'not' to include it. The example below will exclude the current entry page. You can replace "#{entry.id}" with the ID of the entry you want to exclude.</p>

<pre><code>{% set results = craft.entries({
  'id': "not #{entry.id}",
  'search': query,
  'order': 'score'
}) %}
</code></pre>

CC BY-SA 3.0
2014-11-18T16:15:24.270Z
Sorry if unclear but I wish to exclude all entries of an entry type, not a single entry.
hamishtaplin
CC BY-SA 3.0
2014-11-18T16:14:22.267Z
2014-11-18T16:14:22.267Z
Mark Notton
<p>Going through Craft's docs, I found no easy or official way to do this. Fastest possible way, in my opinion:</p>

<pre><code>{# get all section IDs #}
{% set sections = craft.sections.getAllSections() %}

{# get all entry types for sections #}
{% set entryTypes = [] %}
{% for section in sections %}
    {# exclude the entry type you don't want, add the others to 'entryTypes' variable
       you could, of course, replace handle by ID or whatever you like #}
    {% for entryType in section.getEntryTypes() if entryType.handle != 'handleToExclude' %}
        {% set entryTypes = entryTypes | merge([entryType]) %}
    {% endfor %}
{% endfor %}

{% set entries = craft.entries.section('inhoud').type(entryTypes) %}
</code></pre>

CC BY-SA 4.0
2018-10-13T06:52:43.663Z
Works for me in Craft 3 with the following modification: `merge([entryType.handle])`
Crafty Cat
CC BY-SA 3.0
2014-11-19T10:04:59.540Z
This is what I tried but it doesn't work—I get 0 results.
hamishtaplin
CC BY-SA 3.0
2014-11-19T11:45:46.873Z
Could you show me your code?
Paul
CC BY-SA 3.0
2014-11-20T09:06:05.187Z
Exactly as you have it there, I get no results.
hamishtaplin
CC BY-SA 3.0
2014-11-20T11:47:42.357Z
Did you replace `entryTypeHandle` with your entry type's handle?
Paul
CC BY-SA 3.0
2014-11-20T12:00:12.453Z
Of course. Also, if I specify a type it works fine, just the 'not' bit seems to break things.
hamishtaplin
CC BY-SA 3.0
2014-11-20T12:29:18.447Z
Ok. You got me there. My solution doesn't work, and after diving into Crafts code I know why: the `type` criterium does not accept 'not'. It only accepts a string containing the entry type's handle, an Int with the entry type's id or an entryTypeModel. Or an array containing one or more of those. Let me think about the best way to work around this for a moment.
Paul
CC BY-SA 3.0
2014-11-20T12:57:38.187Z
Edited my answer, and tested the solution. It works on my side.
Paul
CC BY-SA 3.0
2014-11-20T13:11:20.507Z
Weird isn't it? Could well be a bug.
hamishtaplin
CC BY-SA 3.0
2014-11-20T13:19:08.947Z
Or a missing feature ;)
Paul
CC BY-SA 3.0
2015-01-14T22:48:59.857Z
Bump, missing feature. The not clause works on other fields but not the type field. :(
veritascs
CC BY-SA 4.0
2014-11-18T16:44:44.087Z
2018-08-17T10:14:35.813Z
2018-08-17T10:14:35.813Z
Paul
<p>I would like to fetch all entries apart from those of a specific type: 'chapter'. How do I achieve this with a standard call to 'craft.entries'?</p>

<pre><code>{% set results = craft.entries({
  'search': query,
  'order': 'score'
}) %}
</code></pre>

<entries>
Is it possible exclude an entry type from result of craft.entries?
# Is it possible exclude an entry type from result of craft.entries?

(Asked by: username_0 on 2014-11-18)

I would like to fetch all entries apart from those of a specific type: 'chapter'. How do I achieve this with a standard call to 'craft.entries'?
{% set results = craft.entries({
  'search': query,
  'order': 'score'
}) %}

**Tags:** entries


---

## 3 answers

### Answer by username_4 on 2014-11-18. Score: 7 | Accepted answer

Going through Craft's docs, I found no easy or official way to do this. Fastest possible way, in my opinion:
{# get all section IDs #}
{% set sections = craft.sections.getAllSections() %}

{# get all entry types for sections #}
{% set entryTypes = [] %}
{% for section in sections %}
    {# exclude the entry type you don't want, add the others to 'entryTypes' variable
       you could, of course, replace handle by ID or whatever you like #}
    {% for entryType in section.getEntryTypes() if entryType.handle != 'handleToExclude' %}
        {% set entryTypes = entryTypes | merge([entryType]) %}
    {% endfor %}
{% endfor %}

{% set entries = craft.entries.section('inhoud').type(entryTypes) %}

> **Comments:**
> **username_0**: This is what I tried but it doesn't work—I get 0 results.  
> **username_4**: Could you show me your code?  
> **username_0**: Exactly as you have it there, I get no results.  
> **username_4**: Did you replace `entryTypeHandle` with your entry type's handle?  
> **username_0**: Of course. Also, if I specify a type it works fine, just the 'not' bit seems to break things.  
> **username_4**: Ok. You got me there. My solution doesn't work, and after diving into Crafts code I know why: the `type` criterium does not accept 'not'. It only accepts a string containing the entry type's handle, an Int with the entry type's id or an entryTypeModel. Or an array containing one or more of those. Let me think about the best way to work around this for a moment.  
> **username_4**: Edited my answer, and tested the solution. It works on my side.  
> **username_0**: Weird isn't it? Could well be a bug.  
> **username_4**: Or a missing feature ;)  
> **username_6**: Bump, missing feature. The not clause works on other fields but not the type field. :(  
> **username_5**: Works for me in Craft 3 with the following modification: `merge([entryType.handle])`  

---

### Answer by username_1 on 2020-09-04. Score: 2

If anyone lands on this page same as I did, the far far simpler way to do this is just to include the .type() method and combine it with the 'not' word:
{% set results = craft.entries({
  'search': query,
  'type': 'not chapter',
  'order': 'score'
}) %}

> **Comments:**
> **username_2**: This is the correct modern answer to the OP  

---

### Answer by username_3 on 2014-11-18. Score: 1

You can target the entry by ID and tell it 'not' to include it. The example below will exclude the current entry page. You can replace "#{entry.id}" with the ID of the entry you want to exclude.
{% set results = craft.entries({
  'id': "not #{entry.id}",
  'search': query,
  'order': 'score'
}) %}

> **Comments:**
> **username_0**: Sorry if unclear but I wish to exclude all entries of an entry type, not a single entry.  

---

