• How can be done to do ordering by taxonomy term?

    I have pa_pattern and pa_color. I want to order by pattern first and then by color. Is it possible to do it by relevanssi_orderby?

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi cannot do taxonomy sorting by default, as often taxonomies don’t have a natural order (does it make sense to order colours in alphabetical order?), and not all posts have terms from all taxonomies.

    It doesn’t mean you can’t have it; you just need to build it yourself. The tool for this is the relevanssi_hits_filter hook.

    You need to create a filter function that goes through the results and sorts them in buckets by pa_pattern. Then go through the buckets and sort the posts inside the buckets by pa_color. Then just put the buckets back together in the correct order. There are examples on the documentation page.

Viewing 1 replies (of 1 total)
  • The topic ‘order by taxonomy’ is closed to new replies.