<p>i did {% set categories = craft.categories.descendantOf(1066) %}</p>

<p>And then i did</p>

<p>{% nav category in categories.level(2) %}
{% endnav %}</p>

<p>Always get the answer myself just after i post these damn things.</p>

CC BY-SA 3.0
2015-06-24T16:04:28.237Z
Yep that's the way to do it :) You could also have set the `level` param on the initial `{% set categories ...` line.
Brandon Kelly
CC BY-SA 3.0
2015-06-24T15:02:46.750Z
2015-06-24T15:02:46.750Z
John
<p>Looking at the docs, i can see that the category {% nav %} loop uses the categoryGroup as the starting point. But, i want the first top level category within the category group as the starting point.</p>

<p>So, i want to do something like:</p>

<pre><code>{% set categories = craft.categories.slug('my-first-top-level-cat).first().getChildren() %}

{% nav category in categories %}
&lt;ul&gt;
    &lt;li&gt;
        {{ category.title }}
    &lt;/li&gt;
&lt;/ul&gt;
 {% ifchildren %}

   {% children %}

 {% endifchildren %}
{% endnav %}
</code></pre>

<p>But, doing this only returns the top level, no sub levels.</p>

<p>Also, i want to be able to limit the amount of children output as the there are a few sub trees.</p>

<categories><navigation>
Category Nav tag with control over the depth that {% children %} goes
# Category Nav tag with control over the depth that {% children %} goes

(Asked by: username_0 on 2015-06-24)

Looking at the docs, i can see that the category {% nav %} loop uses the categoryGroup as the starting point. But, i want the first top level category within the category group as the starting point.
So, i want to do something like:
{% set categories = craft.categories.slug('my-first-top-level-cat).first().getChildren() %}

{% nav category in categories %}

    
        {{ category.title }}
    

 {% ifchildren %}

   {% children %}

 {% endifchildren %}
{% endnav %}

But, doing this only returns the top level, no sub levels.
Also, i want to be able to limit the amount of children output as the there are a few sub trees.

**Tags:** categories, navigation


---

## 1 answers

### Answer by username_0 on 2015-06-24. Score: 4

i did {% set categories = craft.categories.descendantOf(1066) %}

And then i did

{% nav category in categories.level(2) %}
{% endnav %}

Always get the answer myself just after i post these damn things.

> **Comments:**
> **username_1**: Yep that's the way to do it :) You could also have set the `level` param on the initial `{% set categories ...` line.  

---

