FacetWP – reset facets if there are no results on pageload

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

/* Add to your (child) theme’s functions.php */

add_action( ‘wp_head’, function() {
?>
<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
if (! FWP.loaded && 0 == FWP.settings.pager.total_rows) {
FWP.loaded = true;
FWP.reset();
}
});
})(jQuery);
</script>
<?php
}, 100 );
{{/gist}}