<p>The paginate tag requires an element query to work and by calling <code>.all()</code> on your queries, you've turned them into an array of elements.</p>

<p>Something like this should work:</p>

<pre><code>{# Grab all of the IDs #}
{% set entries = craft.entries.section('not loanConsultants').search(searchQuery).ids() %}

{% set loanConsultants = craft.entries.section('loanConsultants').type('loanConsultants').search('title:'~searchQuery).ids() %}

{% set branch =   craft.entries.section('loanConsultants').type('branches').search('title:'~searchQuery).ids() %}

{# Merge the IDs together #}
{% set loanConsultantsMerge = loanConsultants|merge(branch) %}
{% set mergeResults = loanConsultantsMerge|merge(entries) %}

{# Build new query #}
{% set results = craft.entries.id($mergeResults) %}

{% paginate results as pageInfo, pageEntries %}
{% for entry in pageEntries %}
    &lt;h5&gt;{{ entry.title }}&lt;/h5&gt;
{% endfor %}

{% if pageInfo.prevUrl %}&lt;a href="{{ pageInfo.prevUrl }}" class="btn btn-success" style="color: blue;"&gt;Previous Page&lt;/a&gt;{% endif %}

{% if pageInfo.nextUrl %}&lt;a href="{{ pageInfo.nextUrl }}" class="btn btn-success" style="color: blue;"&gt;Next Page&lt;/a&gt;{% endif %}
</code></pre>

CC BY-SA 4.0
2019-10-16T22:01:46.407Z
2019-10-16T22:01:46.407Z
Brad Bell
<p>My Code:</p>

<pre><code>{% set Entries              =   craft.entries.section('not loanConsultants').search(searchQuery).orderBy('dateCreated desc').all() %}

{% set loanConsultants      =   craft.entries.section('loanConsultants').type('loanConsultants').search('title:'~searchQuery).orderBy('dateCreated desc').all() %}

{% set Branch               =   craft.entries.section('loanConsultants').type('branches').search('title:'~searchQuery).orderBy('dateCreated desc').all() %}

{% set loanConsultantsMerge = loanConsultants|merge(Branch) %}

{% set mergeResults         = loanConsultantsMerge|merge(Entries) %}
</code></pre>

<p>Pagination code:</p>

<pre><code>{% paginate mergeResults as pageInfo, pageEntries %}
{% for entry in pageEntries %}
    &lt;h5&gt;{{ entry.title }}&lt;/h5&gt;
{% endfor %}

{% if pageInfo.prevUrl %}&lt;a href="{{ pageInfo.prevUrl }}" class="btn btn-success" style="color: blue;"&gt;Previous Page&lt;/a&gt;{% endif %}

{% if pageInfo.nextUrl %}&lt;a href="{{ pageInfo.nextUrl }}" class="btn btn-success" style="color: blue;"&gt;Next Page&lt;/a&gt;{% endif %}
</code></pre>

<craft3>
Craft paginate not working in merge Queries
# Craft paginate not working in merge Queries

(Asked by: username_0 on 2019-10-16)

My Code:
{% set Entries              =   craft.entries.section('not loanConsultants').search(searchQuery).orderBy('dateCreated desc').all() %}

{% set loanConsultants      =   craft.entries.section('loanConsultants').type('loanConsultants').search('title:'~searchQuery).orderBy('dateCreated desc').all() %}

{% set Branch               =   craft.entries.section('loanConsultants').type('branches').search('title:'~searchQuery).orderBy('dateCreated desc').all() %}

{% set loanConsultantsMerge = loanConsultants|merge(Branch) %}

{% set mergeResults         = loanConsultantsMerge|merge(Entries) %}

Pagination code:
{% paginate mergeResults as pageInfo, pageEntries %}
{% for entry in pageEntries %}
    {{ entry.title }}
{% endfor %}

{% if pageInfo.prevUrl %}Previous Page{% endif %}

{% if pageInfo.nextUrl %}Next Page{% endif %}

**Tags:** craft3

---

## 1 answers

### Answer by username_1 on 2019-10-16. Score: 2 | Accepted answer

The paginate tag requires an element query to work and by calling .all() on your queries, you've turned them into an array of elements.
Something like this should work:
{# Grab all of the IDs #}
{% set entries = craft.entries.section('not loanConsultants').search(searchQuery).ids() %}

{% set loanConsultants = craft.entries.section('loanConsultants').type('loanConsultants').search('title:'~searchQuery).ids() %}

{% set branch =   craft.entries.section('loanConsultants').type('branches').search('title:'~searchQuery).ids() %}

{# Merge the IDs together #}
{% set loanConsultantsMerge = loanConsultants|merge(branch) %}
{% set mergeResults = loanConsultantsMerge|merge(entries) %}

{# Build new query #}
{% set results = craft.entries.id($mergeResults) %}

{% paginate results as pageInfo, pageEntries %}
{% for entry in pageEntries %}
    {{ entry.title }}
{% endfor %}

{% if pageInfo.prevUrl %}Previous Page{% endif %}

{% if pageInfo.nextUrl %}Next Page{% endif %}


---

