WP API Menus

plugin banner

Extends the WordPress JSON REST API with new routes pointing to WordPress menus.

Author:Fulvio Notarstefano (profile at wordpress.org)
WordPress version required:3.6.0
WordPress version tested:5.5.0
Plugin version:1.3.2
Added to WordPress repository:18-01-2015
Last updated:18-08-2020
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:8
Plugin URI:https://github.com/nekojira/wp-api-menus
Total downloads:92 516
Active installs:3 000+
plugin download
Click to start download

This plugin extends the WordPress JSON REST API with new routes for WordPress registered menus

The new routes available will be:

  • /menus list of every registered menu.
  • /menus/<id> data for a specific menu.
  • /menu-locations list of all registered theme locations.
  • /menu-locations/<location> data for menu in specified menu in theme location.

Currently, the 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 json_menus_format_menu_item.

An important note on WP API V2:

In V1 the routes are located by default at wp-json/menus/ etc.

In V2 the routes by default are at wp-json/wp-api-menus/v2/ (e.g. wp-json/wp-api-menus/v2/menus/, etc.) since V2 encourages prefixing and version namespacing.


FAQ
ChangeLog