Support

Account

Home Forums Add-ons Repeater Field Post Objects in a Repeater Reply To: Post Objects in a Repeater

  • Hi,

    When you have a loop in a loop, the function like get_the_content() or get_field_object(‘autor’) dont know if they must use the ID of the first “looped” object or the second one …

    To solve it, get the id in variable and use it to clearly indicate which object is focused :

    
    if ( $wp_query->have_posts() ) : ?>
             <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();
                              // Set variables
                              $id = get_the_ID()
                              $title = get_the_title($id );
                              $description = get_the_content($id ); 
                              $field = get_field_object('autor', $id );
                              $colors = $field['value'];
                              $date = get_the_date( 'd.m.Y' );
                              // Output
                              ?>
                                <?php echo $colors;  ?>
                                <?php $wp_query->reset_postdata(); ?>
              <?php endwhile; ?>
       <?php endif; ?>

    Hope it helps.