Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active October 20, 2022 20:49
Show Gist options
  • Save mgibbs189/d750915dbbda6b254f2cd16ae5f53c4b to your computer and use it in GitHub Desktop.
Save mgibbs189/d750915dbbda6b254f2cd16ae5f53c4b to your computer and use it in GitHub Desktop.
FacetWP - show reset button only when facets are selected
<script>
/*
Code placement: see the "Javascript" section on https://facetwp.com/how-to-use-hooks/
This assumes that your reset button looks like this:
<a class="my-reset-btn" onclick="FWP.reset()">RESET</a>
*/
(function($) {
$(document).on('facetwp-loaded', function() {
var qs = FWP.build_query_string();
if ( '' === qs ) { // no facets are selected
$('.your-reset-btn').hide();
}
else {
$('.your-reset-btn').show();
}
});
})(jQuery);
</script>
@mgibbs189
Copy link
Author

@colincny Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment