我有一个自定义的用户类型字段,可以在其中链接附件ID。我正在尝试以编程方式保存附件ID,它看起来很有效,因为当我运行get\\u field($my\\u field)时,我有正确的值。但是,在后端或rest api中看不到更改,它仍然显示旧值。我很困惑,我到底做错了什么?
这是我的代码:
//Update field with attachment ID and user_id
$cover_custom_field_key = "field_5e9ed645b9ec3"; //cover field
$cover_id = media_handle_sideload( $image_file, 0 );
update_field( $cover_custom_field_key, $cover_id, 2 ); //update field for user id=2
echo get_field($cover_custom_field_key, 2); // echo : https://example.com/cover-image/
但在后端,仍然有指向另一个映像的旧链接,在wp json/wp/v2/users/2的rest响应中也有:
"id": 2,
"name": "Mata Hari",
"url": "",
"description": "",
"acf": {
"practice_playlist": false,
"cover": "https://example.com/abstract-colorful-geometric-banner-template-background/"
}