Hide product categories and taxonomy terms in menu if empty
I've been researching this and had no luck so far.
I have a WooCommerce store with a main menu showing product categories (product_cat) and brands (yith_product_brand) which is a custom taxonomy.
I want to hide categories and brands if they are empty. Do you know a way to achieve this, either by using a plugin or adding a function/filter to the functions.php file? If so any help would be much appreciated.
Thanks in advance.
Topic woocommerce-offtopic sub-menu taxonomy custom-taxonomy menus Wordpress
Category Web