diff --git a/.no-sync b/.no-sync index 2911349..75da5d3 100644 --- a/.no-sync +++ b/.no-sync @@ -4,7 +4,7 @@ .gitattributes .gitignore .no-sync -dev.sync.sh .git/ +sync.dev.sh dev dev/ diff --git a/functions.php b/functions.php index 01cbac1..a19f2a2 100644 --- a/functions.php +++ b/functions.php @@ -76,6 +76,19 @@ function ildi_register_sidebars() { ); } +function ildi_nav_remove_empty_terms ( $items, $menu, $args ) { + global $wpdb; + $empty = $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, $empty ) ) ) { + unset( $items[$key] ); + } + } + return $items; +} +add_filter( 'wp_get_nav_menu_items', 'ildi_nav_remove_empty_terms', 10, 3 ); + + // add_action('init', 'register_ildi_menu'); add_action( 'after_setup_theme', 'register_ildi_menus', 0 ); add_action( 'wp_enqueue_scripts', 'ildi_styles' );