Answers.Body: <p>You can only pass <a href="https://github.com/brandonkelly/TwigForDesigners/blob/master/values-expressions-and-variables.md#objects"><strong>an object</strong></a> or an ElementCriteriaModel (what you get when you type 'craft.entries') into <code>getNext()</code> and <code>getPrev()</code>. </p>
  
  <p>Calling <code>find()</code> on an ElementCriteriaModel, as I'm doing in my code, turns it into an actual array of entries, which is not something <code>getNext()</code> and <code>getPrev()</code> can work with. </p>
  
  <p>So changing the first line to this will work:</p>
  
  <pre><code>{% set params = craft.entries.section('leadership').leadershipType(entry.leadershipType) %}
  </code></pre>
  
  <p>Or this using the object syntax for setting parameters:</p>
  
  <pre><code>{% set params = craft.entries({
      section: 'leadership',
      leadershipType: entry.leadershipType
  }) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T17:28:59.397Z
Answers.Text: we had [exactly the same question](http://craftcms.stackexchange.com/questions/52/how-to-link-to-previous-next-entries-in-a-section) this morning already :)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T17:32:46.820Z
Answers.Text: I saw that when posting. My question adds the need to limit by a specific field which is why I posted a new question.
Answers.UserDisplayName: Anna_MediaGirl
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T17:08:21.347Z
Answers.LastActivityDate: 2014-06-12T17:35:22.637Z
Answers.LastEditDate: 2014-06-12T17:35:22.637Z
Answers.UserDisplayName: Anna_MediaGirl
Body: <p>I'm adding prev/next links to a detail page and can't get <code>craft.entries</code> to return the correct entries.</p>
  
  <p><strong>Specifically, I need <code>craft.entries</code> to return entries in the "leadership" section where the <code>leadershipType</code> field matches the current entry's <code>leadershipType</code> value.</strong></p>
  
  <p>My code returns all entries instead of the ones specific to my field parameter.</p>
  
  <pre><code>{% set params = craft.entries.section('leadership').find({ leadershipType:entry.leadershipType }) %}
  
  {% set prev = entry.getPrev(params) %}
  {% set next= entry.getNext(params) %}?
  
  {% if prev %}&lt;a href="{{ prev.url }}"&gt;&amp;lt;&lt;/a&gt;{% endif %}
  {% if next %}&lt;a href="{{ next.url }}"&gt;&amp;gt;&lt;/a&gt;{% endif %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-15T22:17:16.513Z
Comments.Text: Sorry for that stupid edit I made yesterday, Anna! Must have been very confused with something.
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-15T22:29:34.417Z
Comments.Text: No problem. Probably my field name using "type" is confusing.
Comments.UserDisplayName: Anna_MediaGirl
Tags: <pagination><previous-next>
Title: How can I show next/previous paging that's limited by specific criteria?
ThreadText: # How can I show next/previous paging that's limited by specific criteria?
  
  (Asked by: username_0 on 2014-06-12)
  
  I'm adding prev/next links to a detail page and can't get `craft.entries` to return the correct entries.
  
  **Specifically, I need `craft.entries` to return entries in the "leadership" section where the `leadershipType` field matches the current entry's `leadershipType` value.**
  
  My code returns all entries instead of the ones specific to my field parameter.
  
  ```
  {% set params = craft.entries.section('leadership').find({ leadershipType:entry.leadershipType }) %}
  
  {% set prev = entry.getPrev(params) %}
  {% set next= entry.getNext(params) %}?
  
  {% if prev %}<a href="{{ prev.url }}">&lt;</a>{% endif %}
  {% if next %}<a href="{{ next.url }}">&gt;</a>{% endif %}
  
  ```
  
  **Tags:** pagination, previous-next
  
  > **Comments:**
  > **username_1**: Sorry for that stupid edit I made yesterday, Anna! Must have been very confused with something.  
  > **username_0**: No problem. Probably my field name using "type" is confusing.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-06-12. Score: 7 | Accepted answer
  
  You can only pass [**an object**](https://github.com/brandonkelly/TwigForDesigners/blob/master/values-expressions-and-variables.md#objects) or an ElementCriteriaModel (what you get when you type 'craft.entries') into `getNext()` and `getPrev()`.
  
  Calling `find()` on an ElementCriteriaModel, as I'm doing in my code, turns it into an actual array of entries, which is not something `getNext()` and `getPrev()` can work with.
  
  So changing the first line to this will work:
  
  ```
  {% set params = craft.entries.section('leadership').leadershipType(entry.leadershipType) %}
  
  ```
  
  Or this using the object syntax for setting parameters:
  
  ```
  {% set params = craft.entries({
      section: 'leadership',
      leadershipType: entry.leadershipType
  }) %}
  
  ```
  
  > **Comments:**
  > **username_1**: we had [exactly the same question](http://craftcms.stackexchange.com/questions/52/how-to-link-to-previous-next-entries-in-a-section) this morning already :)  
  > **username_0**: I saw that when posting. My question adds the need to limit by a specific field which is why I posted a new question.  
  
  ---
  
  