Last active
October 20, 2022 20:49
-
-
Save mgibbs189/d750915dbbda6b254f2cd16ae5f53c4b to your computer and use it in GitHub Desktop.
FacetWP - show reset button only when facets are selected
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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@colincny Thanks for the update!