Order posts on multiple fields #1928
Unanswered
pentastich
asked this question in
Help
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to order posts on multiple fields? For example, our site is for a rowing club, and we have multiple programs. We can use tags to characterize programs as, say, ADULT, YOUTH, or LEARN_TO_ROW, and individual programs can be associated with multiple tags.
Programs can also be ACTIVE or INACTIVE. ACTIVE programs are presented with a "Register now" button.
Currently I have a custom tag template that orders the programs according to a custom field in the post using "getPostsByTags". This works, because I can use values like "A.200" for an active field, and "I.200" for an inactive one.
Each program is presented with a button. For active programs its label is "Register now", and for inactive programs its label is"Get news". We currently change the buttons manually, but it would be convenient if we could avoid the manual changes.
I can layer this on to the current scheme by defining a new handlebars helper to check whether the custom sort order field starts with an "A" or an "I". But logically it would be cleaner if there were two separate attributes "programActive" and "programOrder".
My question is whether there is any way to either have "getPostsByTags" to sort on multiple fields, or, alternatively, to define a "computed field" that incorporates multiple post fields into a single key (analagous to the computed options (https://getpublii.com/dev/computed-options/), but for post fields?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions