通过WP Rest API创建自定义字段的帖子
问题描述:
我正在做一个IONIC应用程序,该项目需要通过Wordpress API与自定义字段(我正在使用ACF Pro和Aires ACF到REST API)创建帖子,我可以创建一个带有REST API的普通帖子,即使是,ACF字段也不会创建或放弃,只有当我在Wordpress管理界面中创建帖子时,才会为帖子创建ACF字段。通过WP Rest API创建自定义字段的帖子
我正在阅读ACF到REST API的文档,但我只看到编辑和显示功能。这是否意味着后期元必须存在?因此,如何提前为后 “创造” 他们
感谢您的帮助
问候
phpadmin后创建:
缺席后荟萃:
答
$json = file_get_contents('PATH/TO/FILE.json');
function the_json_contents($json_to_get){
$json_in_array = json_decode($json_to_get, true); //json string to array
return $json_in_array;
}
function do_stuff_do_json() {
$json_array = the_json_contents($json);
foreach($json_array['id'] as $js) { //assuming we have an 'id' key
$somevariable = $js['someKey'];
$somevariable2 = $js['someOtherKey'];
}
}