Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 12, 2019 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/3d0d5a8d322070f17f0e0bd51ecaac13 to your computer and use it in GitHub Desktop.
Save billerickson/3d0d5a8d322070f17f0e0bd51ecaac13 to your computer and use it in GitHub Desktop.
jQuery(function($){
// Hide empty facets
// @see https://www.billerickson.net/advanced-search-with-searchwp-and-facetwp/#facetwp-hide-empty
$(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();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment