Add ability to grab entries NOT related to category #8992
-
I'm in a situation where it would be very helpful to exclude entries that are NOT part of a specific category. Instead, the only solutions are to do some convoluted array methods |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
In the meantime you can do this: {# Get all the IDs of entries that are related to the category #}
{% set excludedEntryIds = craft.entries()
.relatedTo(myCategory)
.ids() %}
{# Get all the entries, except for those #}
{% set entries = craft.entries()
.id(excludedEntryIds ? ['not']|merge(excludedEntryIds) : null)
.all() %} |
Beta Was this translation helpful? Give feedback.
-
Is this possible now? |
Beta Was this translation helpful? Give feedback.
-
Adding interest to this discussion, would be very useful. |
Beta Was this translation helpful? Give feedback.
-
Yup, just came across the same situation. Brandon's answer works well, however. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
notRelatedTo
+andNotRelatedTo
element query params, plus a correspondingnotRelatedTo
GraphQL argument and “Not Related To” element condition rule, are all coming in Craft 5.4. (#15496)