facetwp close flyout on facetwp-loaded

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** close flyout on facetwp-loaded so that the user doesn’t need to close after facet refreshes **/
add_action( ‘wp_head’, function() { ?>
<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
if (FWP.loaded && $(‘.facetwp-flyout’).hasClass(‘active’) ) {
FWP.flyout.close();
}
});
})(jQuery);
</script>
<?php } );
{{/gist}}