Hide UI Taxonomies that are empty

Forums › Forums › Search & Filter Pro › Hide UI Taxonomies that are empty

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #125464

    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

    Trevor
    #125514

    At this time, that is not possible from within the plugin. I do not know whether this would be possible with javascript.

    Anonymous
    #125661

    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;

    Trevor
    #125675

    Cool. I have edited the post top that in a code block, and then closed the thread for now. Thanks for sharing.

Viewing 4 posts – 1 through 4 (of 4 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.