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.
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.