Support

Account

Home Forums ACF PRO Cloned repeater Reply To: Cloned repeater

  • This is the code I ended up with to handle the cloned repeater:

    function my_acf_sections( $area = '' ) {
        if( ! function_exists( 'get_field' ) ) return;
        $page_id = get_queried_object_id();
        if( have_rows( $area, $page_id ) ) :
            while( have_rows( $area, $page_id ) ) : the_row();
                $section_content = get_sub_field( 'section_content' );
                if( $section_content ) {
                    // Do stuff with fields
                } else {
                    // Handle cloned repeater
                    $clone = get_field_object( $area );
                    if( ! isset( $clone['sub_fields'] ) ) continue;
                    $clone = get_field_object( $area )['sub_fields'][0];
                    if( $clone['_clone'] ) my_acf_sections( $clone['name'] );
                }
            endwhile;
        endif;
    }

    I’m open to suggestions for something better.