Combine entries query, but filter one section by field I would like to combine two sections: blog and recipes.

I need to filter the blog section by a field. I have an entries field on on Blog and I want to query those entries where the field is empty.

{% set posts = craft.entries({
   section: ['blog', 'recipes'],
   limit: 12,
   search:'-location:*'
}) %}



This will not return recipes. I think because the location field isn't present on recipes - only blog.
{% set blogIds = craft.entries({
   section: 'blog',
   search: '-location:*',
   limit: null
}).ids() %}

{% set recipeIds = craft.entries({
   section: 'recipes',
   limit: null
}).ids() %}

{% set entries = craft.entries({
   id: blogIds|merge(recipeIds),
   limit: 12,
})



Limit null is only there incase you're paginating, can be removed else.

This is the easiest way I've found for effectively combining element queries.