thebatclaudio / wp-rest-api-v2-menus

Adding menus endpoints on WP REST API v2
47 stars 23 forks source link

Returning ACF field added at menu level #17

Closed andyarc closed 3 years ago

andyarc commented 5 years ago

https://github.com/thebatclaudio/wp-rest-api-v2-menus/issues/5

Shows values from menu items being returned but can the API return ACF values added at menu level? I'd like to add a 'type' to menus but it isn't represented in the object currently returned.

thebatclaudio commented 5 years ago

Hi, the plugin works also with ACF values in menus and not only in menu items. Can you give me more information about your enviroment (WP version, PHP version ecc.)?

Thank you

andyarc commented 5 years ago

Sure. Running on WP 5.2.2, PHP 7.2 Using ACF for custom fields in two groups. One group assigned to menus and another assigned to menu items with one field in each. The menu field is a select with two options and the menu item is a checkbox. A redux action makes an API call, requests the menu and a redux reducer sets it in state unmanipulated. Every detail about the menu appears in the object including the menu item checkbox values but not the value from the select field against the menu. An example of a menu with one item below. 'noAccess' is the acf field for the menu item but 'menuType' doesn't appear in the parent menu node. I tried changing that field group to menu items to test the field and it worked there but not on parent menus.

menu: { termId: 27, name: 'Helix Navigation', slug: 'helix-navigation', termGroup: 0, termTaxonomyId: 27, taxonomy: 'nav_menu', description: '', parent: 0, count: 20, filter: 'raw', items: { '0': { id: 5752, postAuthor: '1', postDate: '2019-07-01 11:31:01', postDateGmt: '2019-07-01 01:31:01', postContent: '', postTitle: 'Welcome', postExcerpt: '', postStatus: 'publish', commentStatus: 'closed', pingStatus: 'closed', postPassword: '', postName: 'welcome', toPing: '', pinged: '', postModified: '2019-07-04 11:02:40', postModifiedGmt: '2019-07-04 01:02:40', postContentFiltered: '', postParent: 0, guid: 'https:/?p=5752', menuOrder: 1, postType: 'nav_menu_item', postMimeType: '', commentCount: '0', filter: 'raw', dbId: 5752, menuItemParent: '0', objectId: '5752', object: 'custom', type: 'custom', typeLabel: 'Custom Link', title: 'Welcome', url: '/', target: '', attrTitle: '', description: '', classes: [ '' ], xfn: '', noAccess: false }, } } }, }

thebatclaudio commented 5 years ago

Hi @andyarc, I tried to set a custom select field for my menus and it works... :(

image

andyarc commented 5 years ago

Thanks for that. I'll look into our implimentation again on Monday.

Andy

thebatclaudio commented 5 years ago

Hi @andyarc, have you got any news in relation to this issue?