Answer the question
In order to leave comments, you need to log in
How to update acf field in post revision?
Hey! pliz tell me how to update the custom field in the revision of the post?
The fact is that I update the post through the wordpress rest api with the following post request:
$('.edit_document').on('click', function(e) {
e.preventDefault();
let title_form = $('#title')[0].value
let content_form = $('#body-edit')[0].value
let version_form = $('#version')[0].placeholder
let status_doc = "publish"
let ver = String((Number(version_form) + 0.1).toFixed(1))
$.ajax({
url: REST_API_data.root + 'wp/v2/posts/'+doc_id,
method: 'POST',
beforeSend : function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', REST_API_data.nonce );
},
data: {
'title': title_form,
'content': content_form,
'status': status_doc,
'fields': {
'version': ver,
}
},
success: function(d) {
console.log(d);
},
error: function(d) {
console.log(d);
}
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question