Home Plugins wp api menus
WP API Menus logo

WP API Menus

by Fulvio Notarstefano on WordPress.org

Extends WordPress WP REST API with new routes pointing to WordPress menus.

(8)

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/ data for a specific menu.
  • /menu-locations list of all registered theme locations.
  • /menu-locations/ data for menu in specified menu in theme location.

Currently, the menu-locations/ 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/ 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.

Active installations2K+
Weekly downloads
186-4.62%
Version1.3.2
Last updated8/18/2020
WordPress version3.6.0
Tested up to5.5.0
Tags
JSONjson rest apimenuswp-apiwp-rest-api