Custom sorting facet values

  • pridigital
    Participant
    6 months, 3 weeks ago #35706

    Hi there,
    I was wondering if there is a way to custom sort the facet values? I know one can sort them alphabetically or by count, but none of those cases are valid for something like the months of the year: Jan, Feb, Mar… Nov, Dec.
    Thanks!

    pridigital
    Participant
    6 months, 3 weeks ago #35707

    Also, it would make sense to have an option to define the order. Here’s an example

    2021 – Books
    2022 – Books
    2023 – Books

    might look better showing 2023 first 😉

    wpsolr
    Keymaster
    6 months, 3 weeks ago #35712

    You can use hook WPSOLR_Events::WPSOLR_FILTER_UPDATE_FACETS_DATA to reorder facet items to your liking.

    An example can be found in file wpsolr/pro/extensions/seo/class-wpsolr-option-seo.php

    pridigital
    Participant
    6 months, 1 week ago #35892

    Yeap, that did the trick. Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.