Log in Sign up

Reverse the order of entries?

Is it possible to list {{#allEntries}} in reverse order—oldest at the top; newest at the bottom?


2 years ago, 1 replies   developers   Edit question

Not right now, eventually I plan to add the tags required to list entries in reverse order. However, you can solve this using CSS or JS by reversing the order of the DOM nodes containing the entry links, e.g.

<div id="reverse">
{{#allEntries}}
  <a href="{{{url}}}">{{title}}</a><br>
{{/allEntries}}
</div>

<script type="text/javascript">
var parent = document.getElementById('reverse');

for (var i = 1; i < parent.childNodes.length; i++){
  var child = parent.childNodes[i];
  parent.insertBefore(child, parent.firstChild);
}
</script>

There are also CSS-only strategies using Flexbox, e.g.

#reverse {
  display:flex;
  flex-direction: column-reverse;
}
Answered 2 years ago · Edit answer