<p>The <a href="http://buildwithcraft.com/docs/templating/entrymodel#getNextSibling" rel="noreferrer">getNextSibling</a> documentation says:</p>

<blockquote>
  <p>getNextSibling() will return the next sibling whether or not it’s enabled. If you want to get the closest enabled sibling, you can do this instead:</p>
</blockquote>

<pre><code>{% set next = craft.entries.positionedAfter(entry).order('lft asc').first() %}
</code></pre>

<p>Similarly for <a href="http://buildwithcraft.com/docs/templating/entrymodel#getPrevSibling" rel="noreferrer">getPrevSibling</a> to get the previous enabled sibling you can do:</p>

<pre><code>{% set prev = craft.entries.positionedBefore(entry).order('lft desc').first() %}
</code></pre>

CC BY-SA 3.0
2015-12-08T22:09:42.827Z
This 'getNextSibling' thing is something I've stumbled over a couple time. Thanks for the post Marion.
John Morton
CC BY-SA 3.0
2017-03-07T20:58:03.247Z
I'd suggest adding ".siblingOf(entry)" into those suggestions so you only get siblings. Otherwise this answer gives you the next entry regardless of hierarchy :)
JamesNZ
CC BY-SA 3.0
2015-09-21T08:36:07.933Z
2015-09-21T08:36:07.933Z
Marion Newlevant
<p>Just an updated version of Marion's answer for Craft CMS 3 since <code>order</code> and <code>first</code> are deprecated.</p>

<pre><code>{% set prev = craft.entries.positionedBefore(entry).orderBy('lft desc').one() %}

{% set next = craft.entries.positionedAfter(entry).orderBy('lft asc').one() %}
</code></pre>

CC BY-SA 4.0
2018-09-14T12:04:05.260Z
2018-09-14T12:04:05.260Z
Harald Atteneder
<p>I got an entry template from a structured section.<br>
With prev / next nav links at entry bottom.<br>
But the next sibling is deactivated.<br>
So the page return is 404 not found !  </p>

<pre><code>{% set prev = entry.prevSibling %}  
{% set next = entry.nextSibling %}

{% if prev %}
    &lt;a class="nav-prev nav-left" href="{{ prev.url }}"&gt;&lt;&amp;nbsp;{{ prev.title }}&lt;/a&gt;
{% endif %}
{% if next %}
    &lt;a class="nav-next nav-right" href="{{ next.url }}"&gt;{{ next.title }}&amp;nbsp;&gt;&lt;/a&gt;
{% endif %}
</code></pre>

<p>Should it be <code>status=live</code> by default no?  </p>

<entry><status>
Entry next sibling return a deactivated entry
# Entry next sibling return a deactivated entry

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

I got an entry template from a structured section.
With prev / next nav links at entry bottom.
But the next sibling is deactivated.
So the page return is 404 not found !  
{% set prev = entry.prevSibling %}  
{% set next = entry.nextSibling %}

{% if prev %}
    < {{ prev.title }}
{% endif %}
{% if next %}
    {{ next.title }} >
{% endif %}

Should it be status=live by default no?

**Tags:** entry, status

---

## 2 answers

### Answer by username_1 on 2015-09-21. Score: 7

The getNextSibling documentation says:

getNextSibling() will return the next sibling whether or not it’s enabled. If you want to get the closest enabled sibling, you can do this instead:

{% set next = craft.entries.positionedAfter(entry).order('lft asc').first() %}

Similarly for getPrevSibling to get the previous enabled sibling you can do:
{% set prev = craft.entries.positionedBefore(entry).order('lft desc').first() %}

> **Comments:**
> **username_2**: This 'getNextSibling' thing is something I've stumbled over a couple time. Thanks for the post Marion.  
> **username_3**: I'd suggest adding ".siblingOf(entry)" into those suggestions so you only get siblings. Otherwise this answer gives you the next entry regardless of hierarchy :)  

---

### Answer by username_4 on 2018-09-14. Score: 5

Just an updated version of Marion's answer for Craft CMS 3 since order and first are deprecated.
{% set prev = craft.entries.positionedBefore(entry).orderBy('lft desc').one() %}

{% set next = craft.entries.positionedAfter(entry).orderBy('lft asc').one() %}


---

