douwei2966 2014-09-17 20:22
浏览 58
已采纳

通过update_field无人值守地将行添加到ACF的Repeater

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();
    }
}
  • 写回答

1条回答 默认 最新

  • doumi9661 2015-05-29 10:20
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名