<p>If there isn't a "next" sibling, <code>entry.getNext()</code> returns <code>null</code> – in which case you can use Twig's <code>default</code> filter to set an alternative value (i.e. your <em>first</em> entry).</p>

<p>Untested, but something like this should work:</p>

<pre><code>{% set nextEntry = entry.getNext|craft.entries.section('mySectionHandle').first() %}
</code></pre>

CC BY-SA 3.0
2015-06-09T17:29:11.523Z
2015-06-09T17:29:11.523Z
Mats Mikkel Rummelhoff
<p>Is there a way to be able to use <code>entry.getNext(params)</code> to return back to the first entry when you're viewing the last entry in the parameters?</p>

<p>With the result of looping/cycling through all entries and returning to the original.</p>

<entries><forloop><loop>
Next / Prev and looping/cycling entries instead of reaching the end of the selected results
# Next / Prev and looping/cycling entries instead of reaching the end of the selected results

(Asked by: username_0 on 2015-06-09)

Is there a way to be able to use `entry.getNext(params)` to return back to the first entry when you're viewing the last entry in the parameters?

With the result of looping/cycling through all entries and returning to the original.

**Tags:** entries, forloop, loop


---

## 1 answers

### Answer by username_1 on 2015-06-09. Score: 1 | Accepted answer

If there isn't a "next" sibling, entry.getNext() returns null – in which case you can use Twig's default filter to set an alternative value (i.e. your first entry).
Untested, but something like this should work:
{% set nextEntry = entry.getNext|craft.entries.section('mySectionHandle').first() %}


---

