I've looped through individual category groups to find each parent/child category, but is there a way to loop through and only show Category Group names?


I'm not seeing any obvious ways to access groups directly in Twig. There may be a more direct way, idk — but this should work.

{% set categoryGroupNames = [] %}
{% for category in craft.categories %}
    {% set groupName = category.getGroup.name %}
    {% if groupName not in categoryGroupNames %}
        {% set categoryGroupNames = categoryGroupNames|merge([groupName]) %}
    {% endif %}
{% endfor %}

{% for groupName in categoryGroupNames %}
    {{ groupName }}
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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