【发布时间】:2020-06-15 16:04:20
【问题描述】:
我想在 wordpress 前端放一个表格,并能够将数据发布到高级自定义字段中。但是,似乎我只能访问“标题”和“内容”。 我可以专门针对 JS 文件中的自定义字段吗?
在第 5 行代码下方,我尝试使用“getField('chapter'): $(".chapter").val()”,但它不起作用。
postNote(e) {
var ournewPost ={
'title': $(".new-note-title").val(),
'content': $(".new-note-body").val(),
getField('chapter'): $(".chapter").val(),
'status': 'publish'
}
$.ajax({
beforeSend: (xhr) => {
xhr.setRequestHeader('X-WP-Nonce', Data.nonce);
},
url: Data.root_url + '/wp-json/wp/v2/note/',
type: 'POST',
data: newNote,
});
}
【问题讨论】:
标签: wordpress advanced-custom-fields