How to exclude/remove submenu using Walker_Nav_Menu

Filter ‘wp_nav_menu_objects’ would help: add_filter( ‘wp_nav_menu_objects’, ‘remove_sub_items’, 10, 2 ); function remove_sub_items( $items,$args ) { $new_items = array(); for ($i=1;$i<count($items)+1;$i++){ //is lvl0 if(empty($items[$i]->menu_item_parent)){ $new_items= array_merge($new_items, nav_tree($items[$i],$items)); } } // var_dump($new_items); die(); if( $args->theme_location == ‘primary’ ) return $new_items; return $items; } function nav_tree($parent,$items){ $rtn = array(); $rtn[] = $parent; //Edit this conditional, return menu level … Read more

How to hide Newsletter plugin submenus from the Dashboard?

Use the action admin_menu as opposed to admin_init. You also need to adjust your use of remove_submenu_page to match the way Newsletter adds menu items: remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_main_index’ ); remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_main_main’ ); remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_main_diagnostic’ ); remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_subscription_profile’ );

sub-menu does not show on the very top bar

I am not sure how the Hestia theme works but normally, you need to create child pages by setting a parent page in your wp-admin Pages menu. Or by going to Appearances > Menu, here you can create custom menus and set them to different locations.

Get the page IDs of a Particular Menu item’s submenu

You can try the following function: function wpse_290320_get_page_ids_from_menu( $menu_id, $submenu_id ) { $menus = wp_get_nav_menu_items( $menu_id ); $pages = array(); foreach( $menus as $menu ) { if( $submenu_id == $menu->menu_item_parent && ‘page’ == $menu->object ) { $pages[] = $menu->object_id; } } return $pages; } $menu_id = 26; $submenu_id = 3298; $pages = wpse_290320_get_page_ids_from_menu( $menu_id, $submenu_id … Read more