Answers.Body: <p>You can set the <code>prev.url</code> at the top of the template, for example:</p>
  
  <pre><code>{% set criteria = {section: 'blog', order: 'postDate'} %}
  {% set prev = entry.getPrev(criteria) %}
  </code></pre>
  
  <p>Add a link if <code>prev</code> is available:</p>
  
  <pre><code>{% if prev %}
     &lt;a href="{{ prev.url }}"&gt;{{ prev.title }}&lt;/a&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T13:30:55.813Z
Answers.Text: Sorry @Patrick, didn't see you edited your answer before I composed mine. Now pretty much identical.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T12:56:25.097Z
Answers.LastActivityDate: 2017-10-15T13:36:30.837Z
Answers.LastEditDate: 2017-10-15T13:36:30.837Z
Answers.UserDisplayName: Patrick Nesbitt
Answers.Body: <p>For navigating siblings in a <code>structure</code> there's a shortcut:</p>
  <pre class="lang-twig prettyprint-override"><code>{% if entry.prevSibling %}&lt;a href=&quot;{{ entry.prevSibling.url }}&quot;&gt;Previous&lt;/a&gt;{% endif %}
  {% if entry.nextSibling %}&lt;a href=&quot;{{ entry.nextSibling.url }}&quot;&gt;Next&lt;/a&gt;{% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-09T09:33:58.063Z
Answers.LastActivityDate: 2021-03-11T10:30:13.380Z
Answers.LastEditDate: 2021-03-11T10:30:13.380Z
Answers.UserDisplayName: Tamlyn
Answers.Body: <p>You are probably not using this within a craft.entries loop. Position it inside a loop or set custom parameters for your prev and next elements:</p>
  
  <pre><code>{# Set parameters for prev/next elements list #}
  {% set params = craft.entries.section('blog').order('title asc') %}
  
  {# Get the prev/next elements #}
  {% set prevEntry = entry.getPrev(params) %}
  {% set nextEntry = entry.getNext(params) %}
  
  {# And make sure to only output the links if the element exists #}
  {% if prevEntry %}&lt;a href="{{ prevEntry.url }}"&gt;Previous&lt;/a&gt;{% endif %}
  {% if nextEntry %}&lt;a href="{{ nextEntry.url }}"&gt;Next&lt;/a&gt;{% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-06T09:30:58.023Z
Answers.Text: For anyone in the same position has me who has a few entries with identical post dates (both date and time are the same), for this to work properly if ordering by post date, you also need to specify the secondary sort parameter Craft uses, which, from a quick inspect of the entries section of the CMS seems to be id (ascending). So the full criteria would be `craft.entries.section(mySection).order('postDate desc, id asc')`.
Answers.UserDisplayName: Mike Vaux
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-11T17:06:01.880Z
Answers.Text: How do I get this to work in Craft 3? I can get the prev & next urls via the paginate tag but I'm stuck on how to retrieve the entry titles...
Answers.UserDisplayName: erwinheiser
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T13:56:59.690Z
Answers.Text: Thanks, I assumed that the `entry` already set for the URL I'm viewing would know about what came before and after.
Answers.UserDisplayName: Derek Hogue
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T13:24:37.450Z
Answers.LastActivityDate: 2014-06-12T18:34:48.250Z
Answers.LastEditDate: 2014-06-12T18:34:48.250Z
Answers.UserDisplayName: carlcs
Body: <p>What would be the equivalent in Craft of ExpressionEngine's <a href="http://ellislab.com/expressionengine/user-guide/add-ons/channel/entry_linking.html">Next/Previous entry linking</a>? I was looking at <code>getNext()</code> and <code>getPrev()</code> (and their aliases <code>next</code> and <code>prev</code>) (via the <a href="http://buildwithcraft.com/docs/templating/entrymodel">EntryModel docs</a>), but when I try the obvious:</p>
  
  <pre><code>&lt;a href="{{ entry.prev.url }}"&gt;Previously: {{ entry.prev.title }}&lt;/a&gt;
  </code></pre>
  
  <p>I just get the current entry's data.</p>
  
  <p>What piece am I missing here?</p>
  
Tags: <pagination><navigation><entrymodel>
Title: How to link to previous/next entries in a section?
ThreadText: # How to link to previous/next entries in a section?
  
  (Asked by: username_0 on 2014-06-12)
  
  What would be the equivalent in Craft of ExpressionEngine's [Next/Previous entry linking](http://ellislab.com/expressionengine/user-guide/add-ons/channel/entry_linking.html)? I was looking at `getNext()` and `getPrev()` (and their aliases `next` and `prev`) (via the [EntryModel docs](http://buildwithcraft.com/docs/templating/entrymodel)), but when I try the obvious:
  
  ```
  <a href="{{ entry.prev.url }}">Previously: {{ entry.prev.title }}</a>
  
  ```
  
  I just get the current entry's data.
  
  What piece am I missing here?
  
  **Tags:** pagination, navigation, entrymodel
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2014-06-12. Score: 62 | Accepted answer
  
  You are probably not using this within a craft.entries loop. Position it inside a loop or set custom parameters for your prev and next elements:
  
  ```
  {# Set parameters for prev/next elements list #}
  {% set params = craft.entries.section('blog').order('title asc') %}
  
  {# Get the prev/next elements #}
  {% set prevEntry = entry.getPrev(params) %}
  {% set nextEntry = entry.getNext(params) %}
  
  {# And make sure to only output the links if the element exists #}
  {% if prevEntry %}<a href="{{ prevEntry.url }}">Previous</a>{% endif %}
  {% if nextEntry %}<a href="{{ nextEntry.url }}">Next</a>{% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, I assumed that the `entry` already set for the URL I'm viewing would know about what came before and after.  
  > **username_4**: For anyone in the same position has me who has a few entries with identical post dates (both date and time are the same), for this to work properly if ordering by post date, you also need to specify the secondary sort parameter Craft uses, which, from a quick inspect of the entries section of the CMS seems to be id (ascending). So the full criteria would be `craft.entries.section(mySection).order('postDate desc, id asc')`.  
  > **username_5**: How do I get this to work in Craft 3? I can get the prev & next urls via the paginate tag but I'm stuck on how to retrieve the entry titles...  
  
  ---
  
  ### Answer by username_1 on 2014-06-12. Score: 20
  
  You can set the `prev.url` at the top of the template, for example:
  
  ```
  {% set criteria = {section: 'blog', order: 'postDate'} %}
  {% set prev = entry.getPrev(criteria) %}
  
  ```
  
  Add a link if `prev` is available:
  
  ```
  {% if prev %}
     <a href="{{ prev.url }}">{{ prev.title }}</a>
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_2**: Sorry @username_1, didn't see you edited your answer before I composed mine. Now pretty much identical.  
  
  ---
  
  ### Answer by username_3 on 2021-03-09. Score: 3
  
  For navigating siblings in a `structure` there's a shortcut:
  
  ```twig
  {% if entry.prevSibling %}<a href="{{ entry.prevSibling.url }}">Previous</a>{% endif %}
  {% if entry.nextSibling %}<a href="{{ entry.nextSibling.url }}">Next</a>{% endif %}
  
  ```
  
  
  ---
  
  