<p>The way I usually accomplish this is to add a "Hide From Nav" Lightswitch field to the sections I want to filter.</p>

<p>This will filter out any entries where the Lightswitch is "on".</p>

<pre><code>{% set subnav = craft.entries.descendantOf(mainEntry).hideFromNav('not 1').level(2) %}
</code></pre>

CC BY-SA 4.0
2019-04-14T00:47:31.560Z
2019-04-14T00:47:31.560Z
Simon Kuran
<p>I have a navigation menu setup but I want to filter out some of the children at level(2) so they aren't showing in the dropdown navigation menu. Here is how I am grabbing the children...</p>

<pre><code>{% set mainEntry = craft.entries.slug(craft.request.getSegment(1)).one() %}
{% set subnav = craft.entries.descendantOf(mainEntry).level(2) %}

&lt;div class="menu"&gt;
            &lt;ul class="no-list-style"&gt;
                &lt;li&gt;&lt;a href="{{mainEntry.getUrl}}"&gt;Home&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="javascript:void(0);"&gt;Conference&lt;/a&gt;&lt;i class="fa fa-chevron-down"&gt;&lt;/i&gt;
                    &lt;div class="sub-menu"&gt;
                        &lt;ul class="no-list-style"&gt;
                            {% for page in subnav %}
                            &lt;li&gt;
                                {{ page.link }} 
                            &lt;/li&gt;
                            {% endfor %}
                        &lt;/ul&gt;
                    &lt;/div&gt;
                &lt;/li&gt;
             &lt;/ul&gt;
          &lt;/div&gt;
</code></pre>

CC BY-SA 4.0
2019-04-12T19:38:36.297Z
Can you add more details on the filtering? Are you just needing to manually pick entries to hide from the nav?
Simon Kuran
CC BY-SA 4.0
2019-04-13T20:49:57.123Z
Yes, is there a way to pick which child entries I want to hide?
user9494
<navigation><descendantof>
How can I filter which children I want to show in a sub navigation menu
# How can I filter which children I want to show in a sub navigation menu

(Asked by: username_0 on 2019-04-11)

I have a navigation menu setup but I want to filter out some of the children at level(2) so they aren't showing in the dropdown navigation menu. Here is how I am grabbing the children...
{% set mainEntry = craft.entries.slug(craft.request.getSegment(1)).one() %}
{% set subnav = craft.entries.descendantOf(mainEntry).level(2) %}


            
                Home
                Conference
                    
                        
                            {% for page in subnav %}
                            
                                {{ page.link }} 
                            
                            {% endfor %}

**Tags:** navigation, descendantof

> **Comments:**
> **username_1**: Can you add more details on the filtering? Are you just needing to manually pick entries to hide from the nav?  
> **username_0**: Yes, is there a way to pick which child entries I want to hide?  

---

## 1 answers

### Answer by username_1 on 2019-04-14. Score: 2

The way I usually accomplish this is to add a "Hide From Nav" Lightswitch field to the sections I want to filter.
This will filter out any entries where the Lightswitch is "on".
{% set subnav = craft.entries.descendantOf(mainEntry).hideFromNav('not 1').level(2) %}


---

