<p>It seems that setting a child category also sets it's parents categories too (top level being first, and selected child category is last).</p>
<p>Able to get the category with <code>{{ asset.categoryField.all()|last.title }}</code></p>

CC BY-SA 4.0
2022-03-01T16:44:53.453Z
2022-03-01T16:44:53.453Z
Jaytrix
<p>I have an asset volume that has a category field. The category field has no max level so I can have parent/child categories.
If I set a child category to the asset in /admin then all is well, but when I go to display the asset and category then I only get the top level (parent) category and not the child category set in /admin.</p>
<p>Similar thing happens if I use the <code>group</code> filter, the groups are only the top level category titles.</p>

CC BY-SA 4.0
2022-03-01T16:11:41.717Z
Please post the relevant part of your Twig template that's generating the incorrect output.
MoritzLost
<assets><category><children>
Asset has a child category but only displays the parent on templates
# Asset has a child category but only displays the parent on templates

(Asked by: username_0 on 2022-03-01)

I have an asset volume that has a category field. The category field has no max level so I can have parent/child categories.
If I set a child category to the asset in /admin then all is well, but when I go to display the asset and category then I only get the top level (parent) category and not the child category set in /admin.

Similar thing happens if I use the `group` filter, the groups are only the top level category titles.

**Tags:** assets, category, children
> **Comments:**
> **username_1**: Please post the relevant part of your Twig template that's generating the incorrect output.  

---

## 1 answers

### Answer by username_0 on 2022-03-01. Score: 2

It seems that setting a child category also sets it's parents categories too (top level being first, and selected child category is last).

Able to get the category with `{{ asset.categoryField.all()|last.title }}`


---

