When we add new page to the WordPress using “wp_insert_post” and insert data to the repeater field on this page using acf update_field function the data is not visible in backend page edit screen.
We are using basic repeater field:
Field name is “features” and it has sub fields “name” and “value”.
$newPage = array(
'post_title' => $pageTitle,
'post_name' => $pageName,
'post_type' => 'page',
'post_status' =>'publish',
'post_parent' => $parent,
);
$pageID = wp_insert_post($newPage);
$value = array(
array(
"name" => "name1",
"value" => 'value1',
),
array(
"name" => "name2",
"value" => 'value2',
),
);
update_field( 'features', $value, $pageID );
After we run the code, page is created but the ‘features’ fields are empty when accessed through backend, although they are set in database (get_field function in front end returns them).
One more notice is that, if we’d created the page using wp_post_insert, then manually published it through backend (publish button) then update_field function works.
How can we fix this, since we have an import of hundreds pages. and manually updating is impossible.