I suspect the only way to do this at the moment would be to look up the EntryType
s for each of the desired Sections, and filter just by those—ignoring the section
query facet. For example:
{# Map some Section handles into actual Section models, using the Sections Service: #}
{% set sections = ['one', 'two', 'three'] | map((h) => craft.app.sections.getSectionByHandle(h) %}
{# List your "forbidden" Entry Types in a `sectionHandle:entryTypeHandle` format, so we can filter them out, in a moment: #}
{% set forbiddenEntryTypes = [
'mySection:entryTypeOne',
'mySection:entryTypeTwo'
] %}
{% set entryTypes = [] %}
{% for section in sections %}
{# Get the section's EntryTypes, filtering out any that don't match our "magic" `section:entryType` values in the "forbidden" array, above: #}
{% set permittedSectionEntryTypes = section.getEntryTypes() | filter((t) => "#{section.handle}:#{t.handle}" not in forbiddenEntryTypes) %}
{# Merge anything that passes the test into the main `entryTypes` array: #}
{% set entryTypes = entryTypes | merge(permittedSectionEntryTypes) %}
{% endfor %}
{% set query = craft.entries({
type: entryTypes
}) %}
This basically works by assuming you want all types from all sections, then filtering out just a few types from that list.
For example, your forbiddenEntryTypes
might look something like this, if you had three other Entry Types in the Courses section…
{% set forbiddenEntryTypes = [
'courses:night',
'courses:takeHome'
] %}
…where cce
is allowed, because it's returned by the section, but not explicitly filtered out. You'll have to update this if/when you add more Course types!
Keep in mind that the sectionHandle:entryTypeHandle
format is not a Craft feature, it's just a way for us to compare Section + Entry Type handles at once (note the way we build the "#{section.handle}:#{t.handle}"
string when filtering down the Entry types)!