Created
September 1, 2020 12:53
-
-
Save mgibbs189/d37f3f717b20dbd5d56c476da073fffd to your computer and use it in GitHub Desktop.
FacetWP - force no results when proximity is empty
This file contains hidden or 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_pre_filtered_post_ids', function( $post_ids, $class ) { | |
| $facet_name = 'senior_living_proximity'; | |
| if ( empty( $class->facets[ $facet_name ]['selected_values'] ) ) { | |
| $post_ids = [ 0 ]; // force a 0-filled (empty) array | |
| } | |
| return $post_ids; | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment