Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created September 1, 2020 12:53
Show Gist options
  • Select an option

  • Save mgibbs189/d37f3f717b20dbd5d56c476da073fffd to your computer and use it in GitHub Desktop.

Select an option

Save mgibbs189/d37f3f717b20dbd5d56c476da073fffd to your computer and use it in GitHub Desktop.
FacetWP - force no results when proximity is empty
<?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