- This topic has 3 replies, 2 voices, and was last updated 8 years, 7 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
These forums are now closed and remain for historical purposes.
None of the content applies to the new version 3. For support, get in touch via our contact form.
Forums › Forums › Search & Filter Pro › Hide UI Taxonomies that are empty
I am using S&F Pro 2.3.4 with WooCommerce. I have filtering in the shop which is working great, however I want to hide filters that are empty.
So for example, if I’m in the T-Shirts category, the filtering taxonomy type “Flavour” wouldn’t return any products. At the moment it displays the filter in the li, with a h4 title.
Is it possible to add a class to the filter li, such as “empty” so I can target with CSS? Because at the moment there are titles appearing with no filter options below as they’re not applicable.
Kind regards
Liam
I’ve just achieved what I want using JS. For anybody else that might want it:
$('#product_list .product_filters form ul li ul').each(function() {
if(!$(this).has('li').length) {
$(this).parent().addClass('empty');
}
});
The li of each filter, checks whether it has any li’s within it’s child li and if not (shows it’s empty) adds a class of “empty” to the filter li, which you can then target with CSS to display:none;