No sidebar menu if no subpages Resolved Requested: 2 years and 11 months ago Hello, is there any option for disable Advanced Sidebar Navigation Menu widget if there are no subpages? I want to avoid sidebar menu with one item. ThanksPaul
OnPoint Plugins 2 years and 11 months ago Hi Paul, This may be accomplished by adding the following filter to your active theme’s functions.php file: use Advanced_Sidebar_Menu\Nav_Menu\Objects; use Advanced_Sidebar_Menu\Widget\Navigation_Menu; add_filter( 'advanced-sidebar-menu/menus/navigation/is-displayed', function ( ...$args ) { $instance = $args[2]; $nav_menu = wp_get_nav_menu_object( $instance[ Navigation_Menu::NAVIGATION_MENU ] ); if ( ! empty( $nav_menu ) ) { $menu_items = wp_get_nav_menu_items( $nav_menu ); _wp_menu_item_classes_by_context( $menu_items ); $objects = Objects::factory( $menu_items ); $objects->remove_all_non_family_items(); return count( $objects->menu_items ) > 1; } return $args[0]; }, 10, 4 ); Note: For this filter to work, you must have “Display the current item’s section only” checked in your widget options, which you currently do. Have a great day!
Hi Paul,
This may be accomplished by adding the following filter to your active theme’s functions.php file:
Note: For this filter to work, you must have “Display the current item’s section only” checked in your widget options, which you currently do.
Have a great day!
Thanks very much. It works.
P.