FacetWP sorting order after a filter action / search

TL;DR

So I have been tinkering with writing down some solutions I have encountered which I haven’t found a solution for on the internet. Although al lot could be found by using the correct and/or alternative search terms.

One of these issues was a simple: “Keep sorting order of FacetWP instead for search relavance”.

Background information

For IAB, a project I work on with the wonderful Monique Dubbelman and Luc Princen, I built a sweet custom overview of Woocommerce Product Variants. Each product and it’s variant is a course and each coursedate you can book.

So it was more then logical to sort this overview on the startdate. After a search action via the FacetWP search facet it lost it’s sorting by date. This can be disabled, to keep to original sorting, which was set via the pre_get_posts action.

I found this filter by coincidence in the code and now had the correct term to search for, ironic isn’t it :). Because I was searching on “FacetWP sorting order search” and only found articles about changing the “Sorting order” dropdown.

Relevancy sort

This is what the documentation says about filter for adjusting the sorting order after using the Search Facet:

With a search facet is in use, the results are automatically ordered by relevancy. To disable this feature, add the following code:

FacetWP
add_filter( 'facetwp_use_search_relevancy', '__return_false' );

So here it is, an post with some keywords so my future colleages get a hit while searching for a solution.