wp_get_nav_menu_items( $menu ) retrieves all the menu item objects for a menu, but you have to specify the menu ID or menu name.
Here’s how to retrieve the menu items for the menu that is in a specific theme location (ex: primary).
$location = 'primary'; $theme_locations = get_nav_menu_locations(); if( empty( $theme_locations[ $location ] ) ) return; $menu_items = wp_get_nav_menu_items( $theme_locations[ $location ] );
Join Our Team at CultivateWP
We design and build high-performance custom WordPress themes for market leading web publishers. We're looking for designers & developers to join our team.