<p>Try rewriting your element query like so...</p>

<p><code>craft.entries
.section(['etiquette','style','culture'])
.requiredReading(true)
.orderBy('id desc')
.limit(12)
.all()</code></p>

<p>In Craft you can do queries against fields in this way. The <code>where()</code> isn't necessary for what you're trying to achieve.</p>

CC BY-SA 4.0
2018-08-17T18:18:51.437Z
2018-08-17T18:18:51.437Z
Mutual
<p>So I have three light switches on my blog: 'featured', 'required reading' and 'skills'.</p>

<p>I got the featured section to work with this code:</p>

<pre><code>{% for entry in craft.entries
    .section(['etiquette', 'style','culture','reviews'])
    .where('featured' == 1)
    .orderBy('id desc')
    .limit(4)
    .all()
%}
</code></pre>

<p>but when I went to do the reading section I used this code:</p>

<pre><code>{% for entry in craft.entries
    .section([
        'etiquette',
        'style',
        'culture'
    ])
    .where('requiredReading' == 1)
    .orderBy('id desc')
    .limit(12)
    .all()
%}
</code></pre>

<p>but i get all the stories with reading and featured switches on. I checked the database and the required reading field is 0. How can I get just the required reading or can you not use more than one lightswitch?</p>

<entries><database><entry-type><query><lightswitch>
Showing entries for light switch
# Showing entries for light switch

(Asked by: username_0 on 2018-08-16)

So I have three light switches on my blog: 'featured', 'required reading' and 'skills'.
I got the featured section to work with this code:
{% for entry in craft.entries
    .section(['etiquette', 'style','culture','reviews'])
    .where('featured' == 1)
    .orderBy('id desc')
    .limit(4)
    .all()
%}

but when I went to do the reading section I used this code:
{% for entry in craft.entries
    .section([
        'etiquette',
        'style',
        'culture'
    ])
    .where('requiredReading' == 1)
    .orderBy('id desc')
    .limit(12)
    .all()
%}

but i get all the stories with reading and featured switches on. I checked the database and the required reading field is 0. How can I get just the required reading or can you not use more than one lightswitch?

**Tags:** entries, database, entry-type, query, lightswitch


---

## 1 answers

### Answer by username_1 on 2018-08-17. Score: 3

Try rewriting your element query like so...

`craft.entries
.section(['etiquette','style','culture'])
.requiredReading(true)
.orderBy('id desc')
.limit(12)
.all()`

In Craft you can do queries against fields in this way. The `where()` isn't necessary for what you're trying to achieve.


---

