<pre><code>{% 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,
})

</code></pre>

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

<p>This is the easiest way I've found for effectively combining element queries.</p>

CC BY-SA 4.0
2019-08-12T17:27:20.187Z
wouldn't i still be querying possibly hundreds of entries?
Cat Named Dog
CC BY-SA 4.0
2019-08-13T07:55:08.560Z
You would be querying potentially hundreds of IDs (a single column from a single DB table, which is a fairly efficient query), however the end entry query has limit: 12 (the same as your question). 

Your other option is to query 12 of each and then sort them by postDate.

Combining element queries with different criteria for different sections is not (as far as I'm aware) possible in craft
Nick
CC BY-SA 4.0
2019-08-12T16:11:36.720Z
2019-08-12T16:11:36.720Z
Nick
<p>I would like to combine two sections: blog and recipes.</p>

<p>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.</p>

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

</code></pre>

<p>This will not return recipes. I think because the location field isn't present on recipes - only blog.</p>

<entries>
Combine entries query, but filter one section by field
# Combine entries query, but filter one section by field

(Asked by: username_0 on 2019-08-07)

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.

**Tags:** entries

---

## 1 answers

### Answer by username_1 on 2019-08-12. Score: 2

{% 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.

> **Comments:**
> **username_0**: wouldn't i still be querying possibly hundreds of entries?  
> **username_1**: You would be querying potentially hundreds of IDs (a single column from a single DB table, which is a fairly efficient query), however the end entry query has limit: 12 (the same as your question).   Your other option is to query 12 of each and then sort them by postDate.  Combining element queries with different criteria for different sections is not (as far as I'm aware) possible in craft  

---

