Exclude certain entries and its children from navigation 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!
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) %}