Sign in

Order posts by additional field

  • This topic has 1 reply, 2 voices, and was last updated 7 months, 4 weeks ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8369
    Avatar photonmakeiew

    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 photoTomasz Dziuda

    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.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.