<p>Something like this should work:</p>

<pre><code>% for category in craft.categories.level(1).enabled(true) %}
    # only enabled categories
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-06-06T00:20:44.227Z
It worked! Thank you. Couldn't find anything in the docs about this and thought I was losing my mind
Chris
CC BY-SA 3.0
2017-06-05T20:56:18.803Z
2017-06-05T20:56:18.803Z
Brad Bell
<p>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 <code>for</code> loop.</p>

<p>This works:</p>

<pre><code>{% for category in craft.categories.level(1) if category.enabled %}
  # only enabled categories
{% endfor %}
</code></pre>

<p>but instantiates the disabled categories, even though they won't be used.</p>

<templating><categories><query>
Query for enabled categories
# Query for enabled categories

(Asked by: username_0 on 2017-06-05)

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.

**Tags:** templating, categories, query

---

## 1 answers

### Answer by username_1 on 2017-06-05. Score: 2 | Accepted answer

Something like this should work:
% for category in craft.categories.level(1).enabled(true) %}
    # only enabled categories
{% endfor %}

> **Comments:**
> **username_0**: It worked! Thank you. Couldn't find anything in the docs about this and thought I was losing my mind  

---

