问题
I am trying to update a custom field via the WordPress API. The custom field is within an Advanced Custom Fields repeating layout and I cannot figure out how to update it.
I have authentication set up and can update a post status, but I'm not having any luck in updating the ACF data.
Using Postman : Page status can be updated with http://localhost:9000/wp-json/wp/v2/pages/4564/?status=public
. Is there a similar value which can be used to update the ACF field or a way to update by passing JSON instead?
{
"id": 4564,
...
"acf": {
"insert_to_head": "",
"insert_to_foot": "",
"Layout": [
{
"acf_fc_layout": "cert_challenge_pin",
"challenge_pin": "0527881"
}]
}
The ACF to REST API plugin is in use and fields can be viewed via the API but not updated.
Having exhausted search and documentation, any help would be greatly appreciated!
回答1:
I found from this post that you should use the key fields
instead of acf
. In addition, I had to send a Content-type: application/json
header to get it working.
来源:https://stackoverflow.com/questions/53596688/update-acf-fields-inside-layout-via-wp-api