Skip to content

Instantly share code, notes, and snippets.

@Tuarisa
Created October 5, 2018 07:13
Show Gist options
  • Save Tuarisa/a03a66709873854199c4f5831ea33dbb to your computer and use it in GitHub Desktop.
Save Tuarisa/a03a66709873854199c4f5831ea33dbb to your computer and use it in GitHub Desktop.
<?php
function get_menu() {
# Change 'menu' to your own navigation slug.
return wp_get_nav_menu_items('menu');
}
add_action( 'rest_api_init', function () {
register_rest_route( 'custom', '/menu', array(
'methods' => 'GET',
'callback' => 'get_menu',
) );
} );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment