Created
May 28, 2020 14:26
-
-
Save mgibbs189/11d5466096f88856322ecf58dc66dea9 to your computer and use it in GitHub Desktop.
FacetWP - preserve relevancy if both a search and proximity facet are in use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add to your (child) theme's functions.php | |
add_filter( 'facetwp_filtered_post_ids', function( $post_ids ) { | |
$facets = FWP()->facet->facets; | |
if ( isset( $facets['keywords'] ) && ! empty( $facets['keywords']['selected_values'] ) ) { | |
remove_filter( 'facetwp_filtered_post_ids', [ FWP()->helper->facet_types['proximity'], 'sort_by_distance' ] ); | |
} | |
return $post_ids; | |
}, 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment