需要帮助以通过WP API更新ACF中的值
我正在尝试使用WordPress API通过PHP中的WordPress ACF插件中的“行”功能更新一个项目。
我想更改的价值是“星期一”,
这是终点的JSON:
{
"id": 765,
"acf": {
"contact": "2150",
"sched": [
{
"field_611218a978d03": "Monday",
"field_6112197d78d04": "00:00:00",
"field_6112199f78d05": "17:00:00"
}
],
},
}
我可以将“ 2150”的值更改为“ 2151”,
'body' => array(
'acf' => array (
'contact' => "2151",
),
)
但我无法更改“星期一”的值,我'VE已经尝试了以下内容:
'body' => array(
'acf' => array (
'sched' => array ( array ( "field_611218a978d03" => "Tuesday")
)
)
以及:
'body' => array(
'acf' => array (
'sched' => array (
[0] => array( "field_611218a978d03" => "Tuesday")
)
)
)
我一直在搜索,并且似乎没有与此特定问题有关的答案。我已经陷入困境了几天。任何帮助都将不胜感激!
编辑: 要回答cbroe,这是我正在使用的代码:
$api_response = wp_remote_post( 'domain.com/wp-json/wp/v2/person/765', array(
'headers' => array('Authorization' => 'Basic ' . base64_encode( 'user:pass' )),
'body' => array(
'acf' => array (
'contact' => '2150',
'sched' => array ( array ( "field_611218a978d03" => "Tuesday")
),
)
));
$body = json_decode( $api_response['body'],true);
I'm trying to update an item particularly with the "rows" feature in WordPress ACF plugin via PHP using Wordpress API.
The value I'm looking to change is "Monday"
Here's the json from the endpoint:
{
"id": 765,
"acf": {
"contact": "2150",
"sched": [
{
"field_611218a978d03": "Monday",
"field_6112197d78d04": "00:00:00",
"field_6112199f78d05": "17:00:00"
}
],
},
}
I can change the value of "2150" to "2151" with the following:
'body' => array(
'acf' => array (
'contact' => "2151",
),
)
But I can't change the value of "Monday", I've already tried the following:
'body' => array(
'acf' => array (
'sched' => array ( array ( "field_611218a978d03" => "Tuesday")
)
)
As well as:
'body' => array(
'acf' => array (
'sched' => array (
[0] => array( "field_611218a978d03" => "Tuesday")
)
)
)
I've been searching and there seems to be no answer pertaining to this specific problem. I've been stumped for days now. Any help would sincerely be appreciated!
Edit:
To answer CBroe this is the code I'm working with:
$api_response = wp_remote_post( 'domain.com/wp-json/wp/v2/person/765', array(
'headers' => array('Authorization' => 'Basic ' . base64_encode( 'user:pass' )),
'body' => array(
'acf' => array (
'contact' => '2150',
'sched' => array ( array ( "field_611218a978d03" => "Tuesday")
),
)
));
$body = json_decode( $api_response['body'],true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论