Я создал настраиваемое поле с именем base_deluxe_price
в Wordpress Rest API, но я не могу добавить значения к ним с помощью вызова AJAX.
var newHotel = {
title: document.getElementById("title").value,
content: document.getElementById("hotel_content").value,
guid: obj.imageURL,
post_mime_type: obj.imgType,
base_deluxe_price: document.getElementById("deluxeRoomPrice").value,
status: "publish"
};
$.ajax({
beforeSend: xhr => {
xhr.setRequestHeader("X-WP-Nonce", travelData.nonce);
},
url: travelData.root_url + "/wp-json/wp/v2/hotels/",
type: "POST",
data: newHotel,
success: response => {
console.log("new hotel added");
console.log(response);
},
error: response => {
console.log("sorry");
console.log(response);
}
});
Я создал настраиваемое поле с помощью register_rest_field
в функциях. php. Код ниже
function traveller_custom_rest()
{
register_rest_field('hotels', 'base_deluxe_price', array(
'get_callback' => null
));
}
Есть ли способ это исправить?