<?php
// Hides a facet if there is only one option left
// Replace 'my_facet_name' with the name of your facet (4x)
add_action( 'facetwp_scripts', function() { ?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
if ( FWP.settings.num_choices.my_facet_name !== 'undefined' && FWP.settings.num_choices.my_facet_name < 2 ) {
$('.facetwp-facet-my_facet_name').addClass( 'facetwp-hidden' );
} else {
$('.facetwp-facet-my_facet_name').removeClass( 'facetwp-hidden' );
}
});
})(fUtil);
</script>
<?php } );