Do not display empty product categories
-
Hi how are you?
I wanted to know if it was possible not to display my categories of products which are empty in the Max MenuI have this code which works well for a “standard” menu but if I put it, the categories which are in the Max Menu, “go out” and are no longer in the column.
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 ) { if ( ! is_admin() ) { 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; }
If you have a direction to look, it would be a pleasure ^_^
Have a nice day
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Do not display empty product categories’ is closed to new replies.