Home › Forums › Add-ons › Repeater Field › Repeater not display in front end › Reply To: Repeater not display in front end
Hey Jon,
All seems fine. I did notice you’re using the ID return method for your image. The setting defaults to an array return so I’ve modified my answer to suit.
I’ve tidied up your code and tested both in and out of the loop within a page template and it works perfectly.
<div class="stats allignfull">
<div class="wp-block-columns has-6-columns">
<?php if( have_rows('stat_repeater') ): ?>
<?php while( have_rows('stat_repeater') ): the_row(); ?>
<div class="wp-block-column">
<div class="wp-block-classic align">
<?php
$image = get_sub_field('stat_image');
if( $image ) {
$url = $image['url']; ?>
<p><img src="<?php echo esc_url($url); ?>" alt="<?php the_sub_field('stat_headline'); ?>" /></p>
<?php } ?>
<p class="headline">
<span class="font-color-blue-dark"><strong><?php the_sub_field('stat_headline'); ?></strong></span>
</p>
<p class="center-text"><?php the_sub_field('stat_text'); ?></p>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
The only reason I could see this not working is if you’re trying to get data from a different page. If this is the case you’d need to include the ID that is the source of the data in the initial query so, it’d be something like this:
<?php
$page = get_page_by_title( 'About' );
$about_page_id = $page->ID;
?>
<?php if( have_rows('stat_repeater', $about_page_id) ): ?>
<?php while( have_rows('stat_repeater', $about_page_id) ): the_row(); ?>
I hope this 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.