<?php
/** change 'Default sort' to the text of your Default label setting of your search facet, be sure to match exactly including case
** https://facetwp.com/help-center/facets/facet-types/sort/#available-options
** change 'my_search_facet' to the name of your search facet (2 places)
** change 'Relevance' to whatever you want the default label to be when using a search facet
**/
add_filter( 'facetwp_i18n', function( $text ) {
if ( 'Default sort' == $text && isset( FWP()->facet->facets['my_search_facet']['selected_values'] ) && !empty( FWP()->facet->facets['search']['selected_values'] ) ) {
return 'Relevance';
}
return $text;
});