diff --git a/packages/gatsby-source-wordpress/src/fetch.js b/packages/gatsby-source-wordpress/src/fetch.js index 211980e9b4a18..f9a01b3bb8633 100644 --- a/packages/gatsby-source-wordpress/src/fetch.js +++ b/packages/gatsby-source-wordpress/src/fetch.js @@ -214,7 +214,23 @@ async function fetchData({ routeResponse.__type = type entities.push(routeResponse) } - + // WordPress exposes the menu items in meta links. + if (type == `wordpress__wp_api_menus_menus`) { + for (let menu of routeResponse) { + if (menu.meta && menu.meta.links && menu.meta.links.self) { + entities = entities.concat( + await fetchData({ + route: { url: menu.meta.links.self, type: `${type}_items` }, + _verbose, + _perPage, + _hostingWPCOM, + _auth, + _accessToken, + }) + ) + } + } + } // TODO : Get the number of created nodes using the nodes in state. let length if (routeResponse && Array.isArray(routeResponse)) {