In a template, I want to show only enabled categories. I can't figure out how to filter the returned categories by only enabled ones, without doing it in the for loop.

This works:

{% for category in craft.categories.level(1) if category.enabled %}
  # only enabled categories
{% endfor %}

but instantiates the disabled categories, even though they won't be used.

1 Answer 1


Something like this should work:

% for category in craft.categories.level(1).enabled(true) %}
    # only enabled categories
{% endfor %}
  • It worked! Thank you. Couldn't find anything in the docs about this and thought I was losing my mind
    – Chris
    Commented Jun 6, 2017 at 0:20

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.