【问题标题】:Add tags to post when inserting one with Wordpress API Rest & ACF使用 Wordpress API Rest & ACF 插入标签时添加标签
【发布时间】:2022-07-17 14:51:31
【问题描述】:

我正在尝试将标签添加到我通过 Rest API 上传的帖子,但我没有收到它,我将标签存储在具有高级自定义字段的自定义字段中,我需要添加它们到上传时帖子本身的标签。

使用wp_set_post_tags 函数,我在添加帖子时将其写入,但我无法将从 api 发送到自定义字段 custom_tags 的数据带给我,目前我有这个代码:

function add_tags_after_api($post_id) {
     wp_set_post_tags( $post_id, $_POST['acf']['custom_tags'], true );
}

add_action( 'save_post', 'add_tags_after_api', 20 );

我也一直在尝试使用 acf/save,但它也不起作用,有什么想法吗?非常感谢。

【问题讨论】:

    标签: php wordpress api rest advanced-custom-fields


    【解决方案1】:

    你能解决这个问题吗?我需要一个解决方案

    【讨论】:

      猜你喜欢
      • 2020-04-27
      • 1970-01-01
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-10
      • 2012-03-22
      相关资源
      最近更新 更多