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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.