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 %}
  • Sorry for that stupid edit I made yesterday, Anna! Must have been very confused with something.
    – carlcs
    Commented Jul 15, 2014 at 22:17
  • No problem. Probably my field name using "type" is confusing. Commented Jul 15, 2014 at 22:29

1 Answer 1


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
}) %}
  • 2
    we had exactly the same question this morning already :)
    – carlcs
    Commented Jun 12, 2014 at 17:28
  • 1
    I saw that when posting. My question adds the need to limit by a specific field which is why I posted a new question. Commented Jun 12, 2014 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.