This plugin extends the WordPress JSON REST API with new routes for WordPress registered menus
The new routes available will be:
/menuslist of every registered menu.
/menus/<id>data for a specific menu.
/menu-locationslist of all registered theme locations.
/menu-locations/<location>data for menu in specified menu in theme location.
menu-locations/<location> route for individual menus will return a tree with full menu hierarchy, with correct menu item order and listing children for each menu item. The
menus/<id> route will output menu details and a flat array of menu items. Item order or if each item has a parent will be indicated in each item attributes, but this route won’t output items as a tree.
You can alter the data arrangement of each individual menu items and children using the filter hook
An important note on WP API V2:
In V1 the routes are located by default at
In V2 the routes by default are at
wp-json/wp-api-menus/v2/menus/, etc.) since V2 encourages prefixing and version namespacing.
This plugin requires having WP API installed and activated or it won’t be of any use.
Install the plugin as you would with any WordPress plugin in your
wp-content/plugins/ directory or equivalent.
Once installed, activate WP API Menus from WordPress plugins dashboard page and you’re ready to go, WP API will respond to new routes and endpoints to your registered menus.
Is this an official extension of WP API?
There’s no such thing.
Will this plugin do ‚X‘ ?
You can submit a pull request to:
However, menu data organization in json is a bit arbitrary and subjective, and that’s why probably hasn’t made it into WP API by the time of writing. You could also fork this plugin altogether and write your json output for a specific use case.
Mitwirkende & Entwickler
„WP API Menus“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:Mitwirkende
Übersetze „WP API Menus“ in deine Sprache.
Interessiert an der Entwicklung?
Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.
- Fix: Address V2 register_rest_route compatibility issue with WP 5.5 (missing permission_callback arg) – props @thefrosty
- Tweak: The
object_slugproperty is now available to get the slug for relative URLs – props @Fahrradflucht
- Fix (V2): Nodes duplication in sublevel menu items, see https://github.com/unfulvio/wp-api-menus/pull/22 – props @bpongvh
- Fix (V2): The items array was empty because it was looking for „ID“ key instead of „id“ – props @Dobbler
- Fix (V1): Check for JSON_API_VERSION constant, as in a mu-plugin installation of WP API 1.0 it will not show up under active_plugins – props @pdufour
- Tweak (V2 only): Use lowercase
idinstead of uppercase
IDin API responses, to match the standard lowercase
idused across WP REST API – props @puredazzle
- Fix: Fixed WP API v1 version detection for WordPress 4.4 – props Thomas Chille
- Enhancement: Added WP REST API v2 support – props @foxpaul
- Misc: Supports WordPress 4.3
- Misc: Minor edits to headers and phpdocs
- Misc: Improved security
- Misc: Supports WordPress 4.2, add composer.json for wp-packagist
- Fix: Fixes bug where duplicate items where created in nested menus – props @josh-taylor
- Tweak: Introduced
json_menus_format_menu_itemfilter hook – props @Noctine
- Misc: Submission to WordPress.org plugins directory.
- Enhancement: Routes for menus in theme locations now include complete tree with item order and nested children
descriptionattribute for individual items is now included in results
- Fix: Fixed typo confusing
- First public release