Answers.Body: <p>What you did is passing array of entries into <code>getNext</code> method. You need to pass <strong>array of query criteria</strong> instead:</p>
  <pre><code>{% set criteria = {section: 'nieuws', order: 'postDate'} %}
  {% set prevEntry = entry.getPrev(criteria) %}
  </code></pre>
  <p>Note that if there is no next or previous entry, <code>getPrev</code> or <code>getNext</code> will return <code>null</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-13T13:36:16.880Z
Answers.LastActivityDate: 2020-08-13T13:36:16.880Z
Answers.UserDisplayName: Piotr Pogorzelski
Answers.Body: <p>This did the trick - I'm assuming a news channel here with datestamped entries.</p>
  
  <pre><code>{% set query = craft.entries
      .section('nieuws')
      .id('not ' ~ entry.id)
      .limit(1) %}
  
  {% set prevEntry = clone(query)
      .postDate('&lt;= ' ~ entry.postDate.timestamp)
      .order('postDate desc')
      .one() %}
  
  {% set nextEntry = clone(query)
      .postDate('&gt;= ' ~ entry.postDate.timestamp)
      .order('postDate asc')
      .one() %}
  
  {% if prevEntry %}
    &lt;p&gt;&lt;a href="{{ prevEntry.url }}"&gt;&lt; {{ prevEntry.title }}&lt;/a&gt;&lt;/p&gt;
  {% endif %}
  
  {% if nextEntry %}
    &lt;p&gt;&lt;a href="{{ nextEntry.url }}"&gt;{{ nextEntry.title }} &gt;&lt;/a&gt;&lt;/p&gt;
  {% endif %}
  </code></pre>
  
  <p>Hat tip to <a href="https://craftcms.stackexchange.com/questions/27269/how-to-get-the-previous-or-next-two-entries">How to get the previous or next two entries</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-11T17:49:24.140Z
Answers.LastActivityDate: 2019-01-11T17:49:24.140Z
Answers.UserDisplayName: erwinheiser
Body: <pre><code>{# Set parameters for prev/next elements list #}
  {% set params = craft.entries.section('nieuws').all() %}
  
  {# Get the prev/next elements #}
  {% set nextEntry = entry.getNext(params) %}
  </code></pre>
  
  <p>This used to work in Craft 2 in v3 I get an unknown property error. I can retrieve the prev and next links via the paginate tag but how do I retrieve the titles of the prev and next entry??</p>
  
Tags: <craft3>
Title: In Craft 3 how do I find the title of the previous and next entry when looping through a channel?
ThreadText: # In Craft 3 how do I find the title of the previous and next entry when looping through a channel?
  
  (Asked by: username_0 on 2019-01-11)
  
  ```
  {# Set parameters for prev/next elements list #}
  {% set params = craft.entries.section('nieuws').all() %}
  
  {# Get the prev/next elements #}
  {% set nextEntry = entry.getNext(params) %}
  
  ```
  
  This used to work in Craft 2 in v3 I get an unknown property error. I can retrieve the prev and next links via the paginate tag but how do I retrieve the titles of the prev and next entry??
  
  **Tags:** craft3
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-08-13. Score: 3 | Accepted answer
  
  What you did is passing array of entries into `getNext` method. You need to pass **array of query criteria** instead:
  
  ```
  {% set criteria = {section: 'nieuws', order: 'postDate'} %}
  {% set prevEntry = entry.getPrev(criteria) %}
  
  ```
  
  Note that if there is no next or previous entry, `getPrev` or `getNext` will return `null`.
  
  
  ---
  
  ### Answer by username_0 on 2019-01-11. Score: 2
  
  This did the trick - I'm assuming a news channel here with datestamped entries.
  
  ```
  {% set query = craft.entries
      .section('nieuws')
      .id('not ' ~ entry.id)
      .limit(1) %}
  
  {% set prevEntry = clone(query)
      .postDate('<= ' ~ entry.postDate.timestamp)
      .order('postDate desc')
      .one() %}
  
  {% set nextEntry = clone(query)
      .postDate('>= ' ~ entry.postDate.timestamp)
      .order('postDate asc')
      .one() %}
  
  {% if prevEntry %}
    <p><a href="{{ prevEntry.url }}">< {{ prevEntry.title }}</a></p>
  {% endif %}
  
  {% if nextEntry %}
    <p><a href="{{ nextEntry.url }}">{{ nextEntry.title }} ></a></p>
  {% endif %}
  
  ```
  
  Hat tip to [How to get the previous or next two entries](https://craftcms.stackexchange.com/questions/27269/how-to-get-the-previous-or-next-two-entries)
  
  
  ---
  
  