Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Order posts by additional field

  • #8369
    Avatar photo[anonymous]

    Hello,

    Is it possible to order tag posts by something else than posts’ id, title, createdAt or modifiedAt?

    I would like to order them by a postViewconfig field I’ve added, like this:

    {{orderby posts ‘postViewConfig.myField’ ‘ASC’}}

    Many thanks for any help given!

    Cheers,

    Nico

    #8489
    Avatar photo[anonymous]

    Hi,

    Sorry it is not possible – the second param can be used only as top level post field, so config fields won’t work. The only solution in this case is to create custom helper based on https://github.com/GetPublii/Publii/blob/master/app/back-end/modules/render-html/handlebars/helpers/orderby.js but please remember that it will work only if you have no pagination on the list. If there is a pagination – you will get only chunks of posts list which you can order per page but not for the whole list.