I'm using acf with reapeters. I'm trying to add a row to a repeater through update_field, however, when I open a post to confirm if it works in wordpress' admin, it kept loading and gave me this error:
Fatal error: Maximum execution time of 30 seconds exceeded.
When I echo $value, I get this: "bool(false)", here's my code:
foreach($dishes as $current_dish)
{
$local_category_id = strval($current_dish['id_CategoriaTicket']);
if($local_category_id == $categoryId)
{
$prueba = $current_category->post_title;
$new_dish = array(
'post_title' => $current_dish['Descripcion'],
'post_status' => 'publish',
//'post_content' =>'',
'post_type' => 'products'
//'post_author' => $user->ID
);
$post_id = wp_insert_post( $new_dish );
global $cpt_onomy;
$cpt_onomy->wp_set_post_terms( $post_id , $prueba, 'categories');
update_post_meta($post_id, 'product_type', "Platillo");
$field_key = 'product1';
$value = get_field($field_key, $post_id);
$value[] = array("price_id" => "2",
"price" => "30",
"location" => 2
);
update_field($field_key, $value, $post_id );
exit();
}
}
the problem is that the field key you are using is not the correct one. you need to go to custom fields menu and from the top screen options show the field key ids. then copy the field key Id of the repeater and use it in the update_field method. is you use field name you will get an infinite loop and a fatal error due to memory leakage.