Home › Forums › ACF PRO › get a repeater-field with an object-field in a repeater-field › Reply To: get a repeater-field with an object-field in a repeater-field
You need to remove the nested setup_postdata() and wp_reset_postdata() and use some other method of referencing these nested posts. This includes using some other variable name for the post object besides $post.
Here is your code with some modification
<?php if ( have_rows( 'repeater_field' ) ) : while ( have_rows( 'repeater_field' ) ) : the_row(); $post_objects = get_sub_field( 'object_field' ); if ( $post_objects ): foreach ( $post_objects as $post ): setup_postdata( $post ); $post_object = get_field( 'object_field' ); if ( $post_object ): if ( have_rows( 'repeater_field', $post_object->ID ) ) : while ( have_rows( 'repeater_field', $post_object->ID ) ) : the_row(); the_sub_field( 'sub_field' ); endwhile; endif; endif; endforeach; wp_reset_postdata(); endif; endwhile; endif; ?>
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.