Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-15T16:04:32.303Z
Answers.Text: We were posting at the same time. Thanks again for your help!
Answers.UserDisplayName: Danielle Frappier
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-15T16:03:23.880Z
Answers.LastActivityDate: 2018-08-15T16:03:23.880Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <query><lightswitch>
Title: Where to put where() for a query looking for a lightswitch field
ThreadText: # 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](https://docs.craftcms.com/v3/dev/element-queries/#param-value-syntax)
  
  ```twig
  {% 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!  
  
  ---
  
  