How to duplicate entries and loop them without getting a Twig or deprecation error? 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;
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 }}   &lt;br&gt;
    {% endfor %}
{% endfor %}