【发布时间】:2020-11-23 18:49:43
【问题描述】:
我正在尝试使用来自 Wordpress 数据库表(来自 API)的数据填充自定义字段,例如“field_123”(在本例中来自 ACF 插件),例如“house”>“square_metres '。
帖子 (cpt) 已经“开箱即用”地显示主要内容,但我想添加更多数据库表来填充其他自定义字段。 (然后我可以稍后在视觉作曲家的不同网格上使用)
我从某事开始,但很快意识到我自己无法解决问题..
global $wpdb;
$new_value = $_POST['acf']['field_123'];
$wpdb->update(
"house",
array(
"square_metres" => $new_value,
),
array( '%s' )
);
}
add_action('acf/save_post', 'update_field', 1);```
Someone any suggestions? Or a push in the right direction? Perhaps there are smarter/easier ways to achieve this.
Thanks!
【问题讨论】:
标签: php database wordpress custom-fields populate