<p>This is solution:</p>
<pre><code>{% set categories = craft.categories().descendantOf(222).descendantDist(3).all() %}
</code></pre>

CC BY-SA 4.0
2023-01-04T23:37:25.103Z
2023-01-04T23:37:25.103Z
Dimi
<p>Please help me to display the categories. I have a category group with a huge category tree. Can I somehow output not the whole group of categories, but only a certain category with its child categories?
My tree looks like this:</p>
<pre><code>+ category 1 (cat_id=111)
++ subcategory 1-1
++ subcategory 1-2
++ subcategory 1-3
+ category 2 (cat_id=222)
++ subcategory 2-1
++ subcategory 2-2
++ subcategory 2-3
</code></pre>
<p>I want to get from my group only this:</p>
<pre><code>+ category 2
++ subcategory 2-1
++ subcategory 2-2
++ subcategory 2-3
</code></pre>
<p>I try to do this to use this construction:</p>
<pre><code>{% set categories = craft.categories().ancestorOf(222).ancestorDist(3).all() %}
</code></pre>
<p>I understand that this construction should take a category with ID 222 and output it and its descendants</p>
<p>But this don't work. What i do wrong? ((</p>

<craft3><categories>
How to display a category on the site?
# How to display a category on the site?

(Asked by: username_0 on 2023-01-04)

Please help me to display the categories. I have a category group with a huge category tree. Can I somehow output not the whole group of categories, but only a certain category with its child categories?
My tree looks like this:
+ category 1 (cat_id=111)
++ subcategory 1-1
++ subcategory 1-2
++ subcategory 1-3
+ category 2 (cat_id=222)
++ subcategory 2-1
++ subcategory 2-2
++ subcategory 2-3

I want to get from my group only this:
+ category 2
++ subcategory 2-1
++ subcategory 2-2
++ subcategory 2-3

I try to do this to use this construction:
{% set categories = craft.categories().ancestorOf(222).ancestorDist(3).all() %}

I understand that this construction should take a category with ID 222 and output it and its descendants
But this don't work. What i do wrong? ((

**Tags:** craft3, categories

---

## 1 answers

### Answer by username_0 on 2023-01-04. Score: 2

This is solution:
{% set categories = craft.categories().descendantOf(222).descendantDist(3).all() %}


---

