2

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? ((

1 Answer 1

2

This is solution:

{% set categories = craft.categories().descendantOf(222).descendantDist(3).all() %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.