I know the long-form method for achieving my goal, but I'm hitting a wall in trying to keep the conditionals down.

Is it possible to search for entries related to a specific category field AND search for entries with no category selection for that same field?

Right now, I can only do the first part. Here's a snippet of a much larger query.

{# get all categories within specific category groups #}
{% set skillsOptions = craft.categories.group('skillsCategories') %}
{% set durationOptions = craft.categories.group('durationCategories') %}

{# working: find all entries with any category selected #}
{# not working: also find all entries with no category selected #}
{% set opportunities = craft.entries.section('opportunities').relatedTo('and',
        targetElement: ['or', skillsOptions],
        field: 'skills'
        targetElement: ['or', durationOptions],
        field: 'duration'

Your Answer

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

Browse other questions tagged or ask your own question.