Answers.Body: <p>Something like this should work:</p>
  
  <pre><code>% for category in craft.categories.level(1).enabled(true) %}
      # only enabled categories
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-06T00:20:44.227Z
Answers.Text: It worked! Thank you. Couldn't find anything in the docs about this and thought I was losing my mind
Answers.UserDisplayName: Chris
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-05T20:56:18.803Z
Answers.LastActivityDate: 2017-06-05T20:56:18.803Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <templating><categories><query>
Title: Query for enabled categories
ThreadText: # 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  
  
  ---
  
  