I’m trying to see if I can query the wordpress API to get all of the items in the menu of the site using Javascript.
I can see that there is a post here on how to do this in php but I don’t know how to translate this to javascript as it seems to be using the internal wordpress PHP API.
There is a great library here and I can see that with the following code I can query the site:
var site = Site('<id>', WPCOM);
site.get(function(err, info){
// `info` data object
});
But I don’t know how to query the menu items or if this is at all possible?
Any help would be appreciated.
I don’t have the rep to put this link in a comment. I have not used it and don’t know if it will do what you need but how about this page: https://wordpress.org/plugins/wp-api-menus/
Since I am posting as an answer, here is some info from that page:
I also found this similar post on wordpress.stackexchange: https://wordpress.stackexchange.com/questions/209381/get-wp-navigation-menu-from-rest-api-v2. It ends up pointing to the same ‘wp-api-menus/’ link.