Hi,
I want to create new records for a simple custom post type which literally has a title and a year. The title is the standard wordpress title and the year is the advanced custom field. When posting via Ajax and jQuery only the title is stored and the year does not. Is there something obvious I am doing wrong?
I have the latest paid version of ACF installed.
$('.submit-qualification').on('click', function (e) {
e.preventDefault();
var newQualification = {
'title': $( '.qualification-title' ).val(),
'field_5ec63bc5b6fe0': $( '.qualification-year' ).val(),
'status': 'draft'
}
$.ajax({
url: myData.root_url + '/wp-json/wp/v2/qualification/',
type: 'POST',
data: newQualification,
beforeSend: (xhr) => {
xhr.setRequestHeader('X-WP-Nonce', myData.nonce);
},
})
.done(function (data) {
console.log(data);
alert(newQualification.field_5ec63bc5b6fe0);
})
.fail(function (jqXHR, textStatus, errorThrown) {
console.log(textStatus + ': ' + errorThrown);
console.warn(jqXHR.responseText);
});
})