Wordpress 中继器内的ACF Check Post对象是唯一的

Wordpress 中继器内的ACF Check Post对象是唯一的,wordpress,advanced-custom-fields,Wordpress,Advanced Custom Fields,我有一些代码将选定的post对象字段添加到中继器-我希望它做的是检查添加该值时该值是否不存在 我的中继器是字段\ 5ee8874a207d2,我的post对象字段是字段\ 5ee8875b207d3。。我尝试在_数组中使用,但未成功。。。如何在保存帖子时检查用户是否尚未选择该帖子对象 function my_save_post_gear_pop( $post_id ) { if( get_post_type($post_id) !== 'trip') { return; } //

我有一些代码将选定的post对象字段添加到中继器-我希望它做的是检查添加该值时该值是否不存在

我的中继器是字段\ 5ee8874a207d2,我的post对象字段是字段\ 5ee8875b207d3。。我尝试在_数组中使用,但未成功。。。如何在保存帖子时检查用户是否尚未选择该帖子对象

function my_save_post_gear_pop( $post_id ) {


if( get_post_type($post_id) !== 'trip') {
    return;
}


// bail early if editing in admin
if( is_admin() ) {
    
    return;
    
}

if( have_rows('field_5ee8874a207d2', $post_id) ) {
    return;
}

// vars
$post = get_post( $post_id );


$person_repeater = get_field('choices', $post_id); $countperson = count($person_repeater);
$post_type = get_post_type($post_id);

delete_field('field_5ee8874a207d2', $post_id);
for($i = 0; $i < $countperson; $i++) {
$field_key = "field_5ee8874a207d2";
$value = get_field($field_key, $post_id);
$value[] = array("field_5ee8875b207d3" => "$person_repeater[$i]");
update_field( $field_key, $value, $post_id );
}



}

add_action('acf/save_post', 'my_save_post_gear_pop');
功能my\u save\u post\u gear\u pop($post\u id){
如果(获取帖子类型($post帖子id)!='trip'){
返回;
}
//如果在管理中编辑,请提前保释
if(is_admin()){
返回;
}
如果(有行('field_5ee8874a207d2',$post_id)){
返回;
}
//瓦尔斯
$post=get\u post($post\u id);
$person\u repeater=get\u字段($choices',$post\u id);$countperson=count($person\u repeater);
$post\u type=get\u post\u type($post\u id);
删除字段('field_5ee8874a207d2',$post_id);
对于($i=0;$i<$countperson;$i++){
$field\u key=“field\u 5ee8874a207d2”;
$value=get\u字段($field\u key,$post\u id);
$value[]=array(“field_5ee8875b207d3”=>“$person_repeater[$i]”);
更新字段($field\u key、$value、$post\u id);
}
}
添加动作(“acf/保存帖子”、“我的保存帖子”、“装备流行”);