<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>

CC BY-SA 4.0
2019-09-17T17:02:22.513Z
Awesome, thank you very much for your help.
moondawg
CC BY-SA 4.0
2019-09-17T16:28:49.967Z
2019-09-17T16:28:49.967Z
dmatthams
<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>

<entries><categories><lightswitch>
Show entries by a certain category AND certain lightswitch
# 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 %}
            {{ entry.title }}
        {% 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 %}
        {{ entry.title }}
    {% endfor %}

{% endif %}

> **Comments:**
> **username_0**: Awesome, thank you very much for your help.  

---

