1

I'm trying to get prev/next entry using positionedAfter and positionedBefore filters but getting weird order on results because order('postDate desc') seems to be ignored.

{% set prevSibling = craft.entries.positionedAfter(entry).order('postDate desc').first() %}

{% set nextSibling = craft.entries.positionedBefore(entry).order('postDate desc').first() %}

Can anyone help?

Andris
  • 11
  • 2

1 Answers1

2

positionedAfter only applies to entries within a structure section (https://craftcms.com/docs/templating/craft.entries#positionedAfter). See this answer for how to get next and previous entries.

darylknight
  • 3,290
  • 18
  • 42
  • Thanks that answer helped, but I still see problem in craft core because I am using structure and order is wrong for positionedAfter and positionedBefore – Andris Sep 27 '17 at 12:10
  • 1
    positionedAfter and positionedBefore will return the entry before/after in the Structure in the CMS, regardless of how you order them on the front end using .order(). If you're using this for a blog, you should be using a channel rather than a structure. – darylknight Sep 27 '17 at 12:49