Support

Account

Home Forums ACF PRO Adding rows in a repeater field

Unread

Adding rows in a repeater field

  • Hi,
    I have a Repeater field and I want to add it to the new row using the function. It works but my problem is that if the custom field has 5 lists, 10 rows have been added.
    Sorry My English is not that good

    function:

    function tr_test_play (){
    
            $cAcf = count(get_post_meta('3072','featured_fields',true));
            $val = get_post_meta('3072','featured_fields',true);
    
            for ($i = 0; $i < $cAcf; $i++) {
                $dl_name = $val[$i]['quality_film'];
    
                $dl_link = $val[$i]['linkdwon_film'];
    
                // set new value
                $field_key = "post_links_body";
                $value = array(
                    "post_link_quality" => $dl_name,
                    "post_link_download" => $dl_link,
                );
                add_row( $field_key, $value, '3072' );
            }
    
    }
    add_action('init','tr_test_play');

    custom field image ( by var_dump):
    custom field

    repeater:
    repeater

Viewing 1 post (of 1 total)

The topic ‘Adding rows in a repeater field’ is closed to new replies.