<p>Instead of duplicating the entries, you could run your <code>entries</code> loop twice (or as many times as you want) maybe?</p>

<pre><code>{% for i in 0..1 %}
    {% for entry in entries %}
        {{ entry.title }}   &lt;br&gt;
    {% endfor %}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2020-02-14T14:32:06.777Z
2020-02-14T14:32:06.777Z
Oli
<p>I'm trying to duplicate entries inside a macro, which will displays duplicated items inside a carousel.</p>

<p>It's not possible to merge Element Queries. Even if it's possible to merge IDs, merging an array of IDs will end up with non-duplicated entries.</p>

<p>This is how I duplicate entries:</p>

<pre><code>{% set entries = entries | merge(entries) %}
</code></pre>

<p>After that, this is how I loop, and the resulting issue:</p>

<ul>
<li><code>for entry in entries.all()</code>

<ul>
<li>→ Twig error: Impossible to invoke a method ("all") on an array;</li>
</ul></li>
<li><code>for entry in entries</code>

<ul>
<li>→ deprecated warning: <em>Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them</em>;</li>
</ul></li>
<li><code>for entry in entries.all() ?? entries</code> or <code>entry in entries ?? entries.all()</code>

<ul>
<li>→ same warning as previous point;</li>
</ul></li>
</ul>

<templating><error-message><loop><merge><deprecation>
How to duplicate entries and loop them without getting a Twig or deprecation error?
# How to duplicate entries and loop them without getting a Twig or deprecation error?

(Asked by: username_0 on 2020-02-14)

I'm trying to duplicate entries inside a macro, which will displays duplicated items inside a carousel.
It's not possible to merge Element Queries. Even if it's possible to merge IDs, merging an array of IDs will end up with non-duplicated entries.
This is how I duplicate entries:
{% set entries = entries | merge(entries) %}

After that, this is how I loop, and the resulting issue:

for entry in entries.all()

→ Twig error: Impossible to invoke a method ("all") on an array;

for entry in entries

→ deprecated warning: Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them;

for entry in entries.all() ?? entries or entry in entries ?? entries.all()

→ same warning as previous point;

**Tags:** templating, error-message, loop, merge, deprecation

---

## 1 answers

### Answer by username_1 on 2020-02-14. Score: 5 | Accepted answer

Instead of duplicating the entries, you could run your entries loop twice (or as many times as you want) maybe?
{% for i in 0..1 %}
    {% for entry in entries %}
        {{ entry.title }}   
    {% endfor %}
{% endfor %}


---

