<p>You can just query for the field value directly <a href="https://docs.craftcms.com/v3/dev/element-queries/#param-value-syntax" rel="nofollow noreferrer">How to use Element Queries</a></p>

<pre class="lang-twig prettyprint-override"><code>{% set featuredEntry = craft.entries({
    section:  ['resources'],
    orderBy:  {postDate: SORT_DESC},
    limit:    1,
    featured: 1,
}).all() %}
</code></pre>

CC BY-SA 4.0
2018-08-15T16:04:32.303Z
We were posting at the same time. Thanks again for your help!
Danielle Frappier
CC BY-SA 4.0
2018-08-15T16:03:23.880Z
2018-08-15T16:03:23.880Z
Robin Schambach
<p>Struggling with syntax here. I'm trying to query entries in the "resources" section, ordered by postDate desc, limit 1 and that also has the lightswitch "featured" as true. Here is what I have.</p>

<pre><code>        {% set featuredEntry = craft.entries({
            section:            'resources',
            orderBy:            'postDate desc',
            limit:              1,
            where:              {'featured': 1},

        }) %}
</code></pre>

<p>Also to note I'm on craft 3.</p>

<query><lightswitch>
Where to put where() for a query looking for a lightswitch field
# Where to put where() for a query looking for a lightswitch field

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

Struggling with syntax here. I'm trying to query entries in the "resources" section, ordered by postDate desc, limit 1 and that also has the lightswitch "featured" as true. Here is what I have.
        {% set featuredEntry = craft.entries({
            section:            'resources',
            orderBy:            'postDate desc',
            limit:              1,
            where:              {'featured': 1},

        }) %}

Also to note I'm on craft 3.

**Tags:** query, lightswitch


---

## 1 answers

### Answer by username_1 on 2018-08-15. Score: 3 | Accepted answer

You can just query for the field value directly How to use Element Queries
{% set featuredEntry = craft.entries({
    section:  ['resources'],
    orderBy:  {postDate: SORT_DESC},
    limit:    1,
    featured: 1,
}).all() %}

> **Comments:**
> **username_0**: We were posting at the same time. Thanks again for your help!  

---

