• Resolved lydia0uk

    (@lydia0uk)


    im facing the following problem:

    Im using woocommerce, OceanWP and ElementorPro all up2date

    I created a Category Menu under Design – Menu and I added all my Woocommerce Categories. Under woocommerce I swtiched on, to hide empty product categories.

    With Elementor I added a Nav Menu linked to the Menu I created. Problem is: It does also show the empty categories. As Im offering seasonal products, it’s difficult to change the “design – menu” everytime thats why I would like to find a solution how to “force” elementor to check if a categroy is empty before showing it and to hide empty categories.

    The problem is just with the menu, when I use blocks like “product archive”, it does correctly hide empty categories.

    Any ideas?
    kind regards
    lydia

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter lydia0uk

    (@lydia0uk)

    hi, I tried with the following and seems like im on the right path but now facing this issue:

    I have categories and subcategories, there are no products in the categories, if there is a subcategorie cos i will add the product there. with this snipp, it does also hide the empty categories with not empty subcategories

    any idea?

    add_filter( 'wp_get_nav_menu_items', 'nav_remove_empty_category_menu_item', 10, 3 );
    function nav_remove_empty_category_menu_item ( $items, $menu, $args ) {
        global $wpdb;
        $nopost = $wpdb->get_col( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE count = 0" );
        foreach ( $items as $key => $item ) {
            if ( ( 'taxonomy' == $item->type ) && ( in_array( $item->object_id, $nopost ) ) ) {
                unset( $items[$key] );
            }
        }
        return $items;
    }

    “Hi,Since you are using our Pro features on your website, you’ll need to open a support ticket at my.elementor.com.

    www.remarpro.com rules state that commercial products are not supported here.”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘hide empty categorie’ is closed to new replies.