Extend WordPress REST API to show slugs for menu items
I had the same challenge, and fixed it by adding it to the response. Example: function get_menu() { # Change ‘menu’ to your own navigation slug. $menu_items = wp_get_nav_menu_items(‘menu’); foreach($menu_items as $menu_item) { // ALTERNATIVE: $slug = get_post_field( ‘post_name’, $menu_item->object_id ); $slug = basename( get_permalink($menu_item->object_id) ); $menu_item->slug = $slug; } return $menu_items; } add_action( ‘rest_api_init’, … Read more