How can I show next/previous paging that's limited by specific criteria? 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 %}&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 %}
You can only pass an object 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
}) %}