Cant get POST [Fields] to Work
-
I just can’t get to POST ACF fields but WP fields are fine.
My HTML Front-End, my custom ACF field is called model as per the example I have added fields and put the field into bracket.
<div class="admin-quick-add"> <h3>Quick Add Post</h3> <input type="text" name="title" placeholder="Title"> <input type="text" name="fields[model]" placeholder="Model"> <textarea name="content" placeholder="Content"></textarea> <button id="quick-add-button">Create Vehicle</button> </div>
I have a Javascript file performing the JSON function this is the snippet to capture the form data.
var ourVehicleData = { "title" : document.querySelector('.admin-quick-add [name="title"]').value, "fields[model]" : document.querySelector('.admin-quick-add [name="fields[model]"]').value, "content" : document.querySelector('.admin-quick-add [name="content"]').value, "status" : "publish" } var createVehicle = new XMLHttpRequest(); createVehicle.open("POST", "https://mywebsiteaddress.com/wp-json/wp/v2/posts"); createVehicle.setRequestHeader("X-WP-Nonce", auth_user.nonce); createVehicle.setRequestHeader("Content-Type", "application/json", "charset=UTF-8"); createVehicle.send(JSON.stringify(ourVehicleData)); });
– I have request version 3 in the settings.
– Both custom fields show in rest and can edit in rest.Any help on this would be much appreciated.
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Cant get POST [Fields] to Work’ is closed to new replies.