2

I have a field (mdFeatured) set up as a lightswitch field type. I am trying to retrieve both featured and non-featured entries:

{% set featuredEntries = craft.entries.section('merchantDirectory').mdFeatured(true).relatedTo(category).find() %}
{% set normalEntries = craft.entries.section('merchantDirectory').mdFeatured(false).relatedTo(category).find() %}

The featured entries are being retrieved properly, but the normal entries are returning both featured entries and normal entries mixed together. Any possibly know why this is not working? I tried replacing "true" and "false" with "1" and "0" but that did not seem to work either.

Thanks!

4

You could try looking for an empty string: mdFeatured('') or prefix 1 or true with not: mdFeatured('not 1').

| improve this answer | |
  • Thank you, that worked. Still feels odd that "false" by itself does not work though. – Nicholas LeBlanc May 1 '15 at 14:34
  • 1
    This doesn't work in Craft 3. I've tried everything I can think of and still nothing. ``` {% set entries = craft.entries.section('pages').hideFromNavigation('not 1') %} '0' false ``` No idea where to go from here. – kinoli Jul 14 '19 at 3:00

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.