Sorting nextListed

Hm, I just tested this in a Starterkit like this:

<?php
$articles = page('notes')->children()->listed()->sortBy('title', 'asc'); // change sort order as you want

foreach ($articles as $article) {
  echo $article->title() . '-' . $article->date()->toDate('Y-m-d') . '<br>';
  echo ($p = $article->getPrev($articles)) ? $p->title() . '<br>' : 'no prev<br>';
}
?>

This gives me the right precedent, no matter how I change the sort order.


(Alt: Shows the current page and underneath the precedent page in a collection sorted by title, asc)

Do you pass the $sortnotes variable to your snippet?

1 Like