Answers.Body: <p>You can add the lightswitch filter to the entries query like so:</p>
  
  <pre><code>{% set category = craft.categories.slug('copier') %}
  {% set entries = craft.entries()
                        .section('products')
                        .relatedTo(category)
                        .color(true)
                        .all() %}
  
  {# If there are any entries, loop through them #}
  {% if entries | length %}
  
      {# For each entry we find, do this #}
      {% for entry in entries %}
          &lt;p&gt;{{ entry.title }}&lt;/p&gt;
      {% endfor %}
  
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-17T17:02:22.513Z
Answers.Text: Awesome, thank you very much for your help.
Answers.UserDisplayName: moondawg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-17T16:28:49.967Z
Answers.LastActivityDate: 2019-09-17T16:28:49.967Z
Answers.UserDisplayName: dmatthams
Body: <p>Just thinking of an easy way for the user to manage products on a site.</p>
  
  <p>Therefore is it possible to display entries by a category and a lightswitch toggle?</p>
  
  <p>IE. Category selected is Photocopiers and Lightswitch is color?</p>
  
  <p>Then check for those and display the entries? Stuck on the syntax:</p>
  
  <pre><code>{% set category = craft.categories.slug('copier') %}
  {% set colortype = craft.entries().section('products').color(true).all() %}
  {% set entries = craft.entries.section('products').relatedTo(category).find() 
  
  *Stuck on the syntax here to add to the query the lightswitch field*
  
   %}
  
  
  
  
      {# If there are any entries, loop through them #}
      {% if entries | length %}
  
          {# For each entry we find, do this #}
          {% for entry in entries %}
              &lt;p&gt;{{ entry.title }}&lt;/p&gt;
          {% endfor %}
  
  {% endif %}
  </code></pre>
  
  <p>TIA :)</p>
  
Tags: <entries><categories><lightswitch>
Title: Show entries by a certain category AND certain lightswitch
ThreadText: # Show entries by a certain category AND certain lightswitch
  
  (Asked by: username_0 on 2019-09-17)
  
  Just thinking of an easy way for the user to manage products on a site.
  
  Therefore is it possible to display entries by a category and a lightswitch toggle?
  
  IE. Category selected is Photocopiers and Lightswitch is color?
  
  Then check for those and display the entries? Stuck on the syntax:
  
  ```
  {% set category = craft.categories.slug('copier') %}
  {% set colortype = craft.entries().section('products').color(true).all() %}
  {% set entries = craft.entries.section('products').relatedTo(category).find() 
  
  *Stuck on the syntax here to add to the query the lightswitch field*
  
   %}
  
      {# If there are any entries, loop through them #}
      {% if entries | length %}
  
          {# For each entry we find, do this #}
          {% for entry in entries %}
              <p>{{ entry.title }}</p>
          {% endfor %}
  
  {% endif %}
  
  ```
  
  TIA :)
  
  **Tags:** entries, categories, lightswitch
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-09-17. Score: 2 | Accepted answer
  
  You can add the lightswitch filter to the entries query like so:
  
  ```
  {% set category = craft.categories.slug('copier') %}
  {% set entries = craft.entries()
                        .section('products')
                        .relatedTo(category)
                        .color(true)
                        .all() %}
  
  {# If there are any entries, loop through them #}
  {% if entries | length %}
  
      {# For each entry we find, do this #}
      {% for entry in entries %}
          <p>{{ entry.title }}</p>
      {% endfor %}
  
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Awesome, thank you very much for your help.  
  
  ---
  
  