Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active June 20, 2022 15:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/b56c08656e9578fd99dc29c1655bab22 to your computer and use it in GitHub Desktop.
Save djrmom/b56c08656e9578fd99dc29c1655bab22 to your computer and use it in GitHub Desktop.
facetwp reset facets on search
<?php
/** reset a facet (facet 2) on submission of different facet (facet 1)
** change 'search' to name of facet 1
** change 'product_categories' to the name of the facet 2
**/
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if ( 'undefined' !== typeof FWP.facets['search'] && FWP.facets['search'].length < 1 ) {
FWP.facets['product_categories'] = [];
}
});
})(jQuery);
</script>
<?php
}, 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment