hide category menus with zero articles
This commit is contained in:
parent
84e38e80ac
commit
75f1a0058a
2
.no-sync
2
.no-sync
@ -4,7 +4,7 @@
|
||||
.gitattributes
|
||||
.gitignore
|
||||
.no-sync
|
||||
dev.sync.sh
|
||||
.git/
|
||||
sync.dev.sh
|
||||
dev
|
||||
dev/
|
||||
|
@ -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' );
|
||||
|
Loading…
Reference in New Issue
Block a user