Answers.Body: <p>If it’s true that the <code>descendantOf</code> param doesn’t allow to pass in multiple entries, you probably need to work around that issue and grab the descendants for each parent entry individually.</p>
  
  <pre><code>{% set parentIds = [3, 4, 5] %}
  {% set excludeIds = parentIds %}
  
  {% for parentId in parentIds %}
      {% set ids = craft.entries.descendantOf(parentId).ids() %}
      {% set excludeIds = excludeIds|merge(ids) %}
  {% endfor %}
  
  {% set idParam = 'and, not ' ~ excludeIds|join(', not ') %}
  
  {% set entries = craft.entries.section('pages').id(idParam) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-21T10:54:34.040Z
Answers.Text: Works like a charm, thank you!I actually don’t know for sure because of decendantOf and multiple entries. But passing multiple entries simply didn’t work so I assumed the rest.
Answers.UserDisplayName: romadev
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-21T10:18:50.953Z
Answers.LastActivityDate: 2016-12-21T10:18:50.953Z
Answers.UserDisplayName: carlcs
Body: <p>I need to split up a navigaton tree. So I try to exclude certain pages from a structure based navigation tree PLUS their children automatically, but don’t seem to get it.</p>
  
  <pre><code>{% nav page in craft.entries.section('pages').id('and,not 3,not 4,not 5') %}
  </code></pre>
  
  <p>Excluding certain entries like this works.</p>
  
  <p>But:</p>
  
  <pre><code>{% nav page in craft.entries.section('pages').descendantOf('and,not 3,not 4,not 5') %}
  </code></pre>
  
  <p>… doesn’t return anything of course, because descendantOf needs one exact ID. But how could I manage to exclude entries 3, 4 and 5 AND all their children from the navigation without calling the exact IDs of all the children?</p>
  
  <p>Thanks!</p>
  
Tags: <entries><navigation><children>
Title: Exclude certain entries and its children from navigation
ThreadText: # Exclude certain entries and its children from navigation
  
  (Asked by: username_0 on 2016-12-21)
  
  I need to split up a navigaton tree. So I try to exclude certain pages from a structure based navigation tree PLUS their children automatically, but don’t seem to get it.
  
  ```
  {% nav page in craft.entries.section('pages').id('and,not 3,not 4,not 5') %}
  
  ```
  
  Excluding certain entries like this works.
  
  But:
  
  ```
  {% nav page in craft.entries.section('pages').descendantOf('and,not 3,not 4,not 5') %}
  
  ```
  
  … doesn’t return anything of course, because descendantOf needs one exact ID. But how could I manage to exclude entries 3, 4 and 5 AND all their children from the navigation without calling the exact IDs of all the children?
  
  Thanks!
  
  **Tags:** entries, navigation, children
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-12-21. Score: 3 | Accepted answer
  
  If it’s true that the `descendantOf` param doesn’t allow to pass in multiple entries, you probably need to work around that issue and grab the descendants for each parent entry individually.
  
  ```
  {% set parentIds = [3, 4, 5] %}
  {% set excludeIds = parentIds %}
  
  {% for parentId in parentIds %}
      {% set ids = craft.entries.descendantOf(parentId).ids() %}
      {% set excludeIds = excludeIds|merge(ids) %}
  {% endfor %}
  
  {% set idParam = 'and, not ' ~ excludeIds|join(', not ') %}
  
  {% set entries = craft.entries.section('pages').id(idParam) %}
  
  ```
  
  > **Comments:**
  > **username_0**: Works like a charm, thank you!I actually don’t know for sure because of decendantOf and multiple entries. But passing multiple entries simply didn’t work so I assumed the rest.  
  
  ---
  
  