Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 高级自定义字段-以编程方式插入post和更新转发器字段_Php_Wordpress_Advanced Custom Fields - Fatal编程技术网

Php 高级自定义字段-以编程方式插入post和更新转发器字段

Php 高级自定义字段-以编程方式插入post和更新转发器字段,php,wordpress,advanced-custom-fields,Php,Wordpress,Advanced Custom Fields,我对插件“高级自定义字段”有一个问题。我的步骤如下: 1。以编程方式创建帖子 $id_post = wp_insert_post(array( 'post_type'=>$post_type, 'post_title'=>$post_title, 'post_status' => 'publish' )); 2。更新与“post_类型”关联的所有转发器字段 问题出在第二点,事实上,当我用Wordpress的界面(带按钮)创建一篇文章,并在代码中手动插

我对插件“高级自定义字段”有一个问题。我的步骤如下:

1。以编程方式创建帖子

$id_post = wp_insert_post(array(
    'post_type'=>$post_type,
    'post_title'=>$post_title, 
    'post_status' => 'publish'
));
2。更新与“post_类型”关联的所有转发器字段

问题出在第二点,事实上,当我用Wordpress的界面(带按钮)创建一篇文章,并在代码中手动插入该文章的id时,它工作得非常好

但是,当我在第二个点以编程方式创建一个post时,即使我以编程方式输入post create的编号,也无法识别repeater字段

仅当使用“插入新内容”按钮创建帖子时才有效

你有什么建议吗


谢谢大家

请参阅以编程方式解释创建和更新字段的教程。

更新acf图像转发器字段:
我已经解决了这个问题!该问题与字段的名称有关。。您必须使用密钥而不是名称。我现在的代码是

$cliente_data = array( array( "id"  => 33 ) ); 
update_field('field_582c2ed4fab65', $cliente_data, $id_post );

我已经解决了这个问题!该问题与字段的名称有关。。您必须使用密钥而不是名称。我现在的代码是$cliente_data=array(array(“id”=>33));更新_字段('field_582c2ed4fab65',$cliente_data,$id_post);谢谢你的评论!你救了我一天。@Andrea你能用一个例子让你的评论成为公认的答案吗。@RauliRajande完成了!两年过去了,让我来处理这个例子:))在哪里定义了
updatecf
函数?
$newIds = wp_insert_post( array(
            'post_title' => $postCSVContent['1'],
            'post_content' => $postCSVContent['2'],
            'post_type' => 'doors',
            'post_status' => 'publish',        
            'post_author'   => 1,
            'post_parent' => $parentId
    ));

    updateAcf( $postCSVContent , $newIds );
$cliente_data = array( array( "id"  => 33 ) ); 
update_field('field_582c2ed4fab65', $cliente_data, $id_post );