I absolutely love Advanced Custom Fields. It’s part of the reason I love using WordPress so much. It makes things very easy for clients, and is a breeze to develop.
Every now and again I struggle to with grabbing and displaying desired data. A recently project required extracting data from a Post Object, within a Repeater. I struggled for at least an hour with tips from Stack Overflow as well as ACF forums without much luck.
Eventually I turned back to the original Post Object documentation for the answer. Basically, you’ll want to grab the Post Object data, then wrap the whole thing in your repeater code.
Here’s how I did it, using Flexslider. My repeater field is
slides and the Post Object field is
<section class="slider"> <?php if( have_rows('slides') ): ?> <div id="slider" class="flexslider"> <ul class="slides"> <?php while ( have_rows('slides') ) : the_row(); ?> <li> <?php $post_object = get_sub_field('featured_projects'); ?> <?php if( $post_object ): ?> <?php $post = $post_object; setup_postdata( $post ); ?> <a href="<?php the_permalink(); ?>"><img src="<?php the_field('featured_image'); ?>" alt="<?php the_title(); ?>" /></a> <?php wp_reset_postdata(); ?> <?php endif; ?> </li> <?php endwhile; ?> </ul> </div> <?php endif; ?> </section>