ACF:更新图库字段在后端不起作用

时间:2018-10-18 作者:Cudos

我试图更新一个图库字段,图像显示在前端,而不是后端。

// I have also tried to use the ACF field name like $field = \'field_xxxxxxxxxxxxx\';

$field = \'images\';

$post_id = 12345;

$attachments_ids = [
    0 => 22222,
    1 => 33333,
    2 => 44444,
    3 => 55555
];

update_field($field, $attachment_ids, $post_id);

2 个回复
SO网友:David Walz

我假设$attachments\\u id是您要保存的新值。

$field = get_field(\'images\');

$attachments_ids = [
    0 => 22222,
    1 => 33333,
    2 => 44444,
    3 => 55555
];

update_field($field, $attachment_ids, $post_id);

SO网友:Corgalore

我也遇到了这个问题。这对我很有用:

似乎只有在为选择器使用field\\u xxxx语法时才有效

    $field = \'field_xxxxxxxxxxxxx\';

    $post_id = 12345;

    $attachments_ids = [
        22222,
        33333,
        44444,
        55555
    ];

    update_field($field, $attachment_ids, $post_id);

结束

相关推荐

ACF:更新图库字段在后端不起作用 - 小码农CODE - 行之有效找到问题解决它

ACF:更新图库字段在后端不起作用

时间:2018-10-18 作者:Cudos

我试图更新一个图库字段,图像显示在前端,而不是后端。

// I have also tried to use the ACF field name like $field = \'field_xxxxxxxxxxxxx\';

$field = \'images\';

$post_id = 12345;

$attachments_ids = [
    0 => 22222,
    1 => 33333,
    2 => 44444,
    3 => 55555
];

update_field($field, $attachment_ids, $post_id);

2 个回复
SO网友:David Walz

我假设$attachments\\u id是您要保存的新值。

$field = get_field(\'images\');

$attachments_ids = [
    0 => 22222,
    1 => 33333,
    2 => 44444,
    3 => 55555
];

update_field($field, $attachment_ids, $post_id);

SO网友:Corgalore

我也遇到了这个问题。这对我很有用:

似乎只有在为选择器使用field\\u xxxx语法时才有效

    $field = \'field_xxxxxxxxxxxxx\';

    $post_id = 12345;

    $attachments_ids = [
        22222,
        33333,
        44444,
        55555
    ];

    update_field($field, $attachment_ids, $post_id);

相关推荐