2

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.

3

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() %}
1
  • We were posting at the same time. Thanks again for your help! – Danielle Frappier Aug 15 '18 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.