→ How to Hide Empty Facets

Using some JavaScript, you can hide facets that contain no values. In this example, each of our facets is contained within an element having the class of widget.

<script>
(function($) {
    $(document).on('facetwp-loaded', function() {
        $.each(FWP.settings.num_choices, function(key, val) {
            var $parent = $('.facetwp-facet-' + key).closest('.widget');
            (0 === val) ? $parent.hide() : $parent.show();
        });
    });
})(jQuery);
</script>

Place this code into your theme’s header.php or (better yet) into a custom javascript file.