airesvsg / acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API
https://wordpress.org/plugins/acf-to-rest-api/
1.33k stars 111 forks source link

Get the key and value from a select field #268

Open CarrDarch opened 6 years ago

CarrDarch commented 6 years ago

Is it possible to retrieve both the key and value from a select type field?

I have a select field which can have multiple selections:

screen shot 2018-09-04 at 09 47 04

The field is set up to have a key and value pair used to make validation easier:

screen shot 2018-09-04 at 09 47 43

However, the API output only returns the keys:

screen shot 2018-09-04 at 09 51 12

Ideally I would like to get an object containing the selected options in a key-value pair, such as:

"development_additional_counties": { "greater-manchester" : "Greater Manchester", "lancashire" : "Lancashire", }

Is there a way of acheiving this?