Answers.Body: <p>In a channel this would be the next entries where the post date is before and after the current entry’s post date. The element queries for it would look like so:</p>
  
  <pre><code>{% set query = craft.entries
      .section('blog')
      .id('not ' ~ entry.id)
      .limit(2) %}
  
  {% set prevEntries = clone(query)
      .postDate('&lt;= ' ~ entry.postDate.timestamp)
      .order('postDate desc')
      .all() %}
  
  {% set nextEntries = clone(query)
      .postDate('&gt;= ' ~ entry.postDate.timestamp)
      .order('postDate asc')
      .all() %}
  </code></pre>
  
  <p>If your sort the entries by title, something like this should work:</p>
  
  <pre><code>{% set prevEntries = clone(query)
      .title('&lt;= ' ~ entry.title)
      .order('title desc')
      .all() %}
  
  {% set nextEntries = clone(query)
      .title('&gt;= ' ~ entry.title)
      .order('title asc')
      .all() %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-13T12:32:47.203Z
Answers.Text: Thanks Christian - looks like maybe I should change the type. The primary way this data is going to be displayed is alphabetically. For some reason I thought "It should be a structure, because they won't be able to re-order them", but perhaps it should be a Structure after all?
Answers.UserDisplayName: darylknight
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-13T12:42:24.780Z
Answers.Text: A channel is probably the right section type if you don’t need manual sort order. I just updated the answer and added an example for alphabetically ordered entries.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-13T12:23:07.290Z
Answers.LastActivityDate: 2018-08-13T12:39:46.220Z
Answers.LastEditDate: 2018-08-13T12:39:46.220Z
Answers.UserDisplayName: carlcs
Body: <p>I have an entry which needs to display the previous two entries, and the next two. I see in the docs there's a <code>nextSiblingOf</code> method. That does nothing in a channel, and in a structure it will only return one entry. I can't see an ability to "offset" the result.</p>
  
  <p>1: Is this possible in a channel</p>
  
  <p>2: What do I need to do to grab the previous/next two entries in either case?</p>
  
Tags: <templating><craft3>
Title: How to get the previous or next two entries
ThreadText: # How to get the previous or next two entries
  
  (Asked by: username_0 on 2018-08-13)
  
  I have an entry which needs to display the previous two entries, and the next two. I see in the docs there's a `nextSiblingOf` method. That does nothing in a channel, and in a structure it will only return one entry. I can't see an ability to "offset" the result.
  
  1: Is this possible in a channel
  
  2: What do I need to do to grab the previous/next two entries in either case?
  
  **Tags:** templating, craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-13. Score: 4 | Accepted answer
  
  In a channel this would be the next entries where the post date is before and after the current entry’s post date. The element queries for it would look like so:
  
  ```
  {% set query = craft.entries
      .section('blog')
      .id('not ' ~ entry.id)
      .limit(2) %}
  
  {% set prevEntries = clone(query)
      .postDate('<= ' ~ entry.postDate.timestamp)
      .order('postDate desc')
      .all() %}
  
  {% set nextEntries = clone(query)
      .postDate('>= ' ~ entry.postDate.timestamp)
      .order('postDate asc')
      .all() %}
  
  ```
  
  If your sort the entries by title, something like this should work:
  
  ```
  {% set prevEntries = clone(query)
      .title('<= ' ~ entry.title)
      .order('title desc')
      .all() %}
  
  {% set nextEntries = clone(query)
      .title('>= ' ~ entry.title)
      .order('title asc')
      .all() %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks Christian - looks like maybe I should change the type. The primary way this data is going to be displayed is alphabetically. For some reason I thought "It should be a structure, because they won't be able to re-order them", but perhaps it should be a Structure after all?  
  > **username_1**: A channel is probably the right section type if you don’t need manual sort order. I just updated the answer and added an example for alphabetically ordered entries.  
  
  ---
  
  