FacetWP – force no results when proximity is empty

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?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 );
{{/gist}}