【问题标题】:Wordpress ACF import by script needs save for Repeater field通过脚本导入 Wordpress ACF 需要保存为 Repeater 字段
【发布时间】:2015-02-19 16:07:55
【问题描述】:

我刚刚制作了一个脚本,用于将 JSON 提要导入 ACF 自定义字段专业版。 当我插入一个只是普通字段的字段时,导入后不需要单击“保存”操作。

update_field('rating', $route['rating'], $post_id);

一切顺利。 但是,当它是转发器字段时,我使用此代码:

$startlocation = array();
$startlocation[] = array(
    'lat' => $route['startingSpot']['location']['lat'],
    'lng' => $route['startingSpot']['location']['lng'],
    'description' => $route['startingSpot']['nl'],
    'direction' => $route['startingSpot']['direction']
);
update_field('startlocation', $startlocation, $post_id );

创建导入的帖子后需要点击。当我再次运行导入时,这些字段已填写完毕。

有谁知道我是否需要不同的脚本,或者在通过脚本创建帖子后,按程序点击保存,以添加所有自定义字段?

提前致谢, 彼得

【问题讨论】:

    标签: wordpress advanced-custom-fields


    【解决方案1】:

    对于行为的中继器字段,您必须使用 field_key 而不是名称。 这就是我的问题的答案。

    $startlocation = array();
        $startlocation[] = array(
        'lat' => $route['startingSpot']['location']['lat'],
        'lng' => $route['startingSpot']['location']['lng'],
        'description' => $route['startingSpot']['nl'],
        'direction' => $route['startingSpot']['direction']
    );
    update_field('field_dhjawhdwkwkhd', $startlocation, $post_id );
    

    【讨论】:

      猜你喜欢
      • 2018-03-27
      • 2019-07-19
      • 2022-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多