Limit wp_nav_menu_objects() only to first-level menu items
depth argument, available in functions attached to wp_nav_menu_objects hook, refers to the max depth of rendered menu (how many menu levels will be visible on site). To change only first-level elements, you can check in the loop if the menu item has a parent. function change_menu($items) { if( !is_front_page() ) { foreach($items as $item) { … Read more