Home › Forums › General Issues › Getting repeater data to display
I’m having some trouble getting repeater data to display in a template.
I’ve simplified my snippet to test this, but perhaps you can help me troubleshoot it.
Here’s the names:
I have a repeater called summary_section, inside that is a field called bulletin_summary.
I’ve reviewed the information here:
And written out this snippet, but the data does not display.
<span class="patrol-bulletin-data">
<?php if( get_field('summary_section') ): ?>
<php while ( has_sub_field('summary_section') ): ?>
<div class='summary-data'>
<?php the_sub_field('bulletin_summary'); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</span>
With the endwhile; in there it returns a syntax error (which may be conflicting with other parts of the template file – is PHP are nested while statements okay?). When I removed the endwhile; the page loads, but the field data doesn’t.
I’ve somehow gotten rid of the endwhile syntax error by cleaning up the comments elsewhere in the template.
But I’m still left with no data displaying. I’ve fleshed out the snippet with the rest of the fields from that repeater field. This is the full code bit that I currently have, but still nothing displays.
<div class="patrol-bulletin-data">
<?php if( get_field('summary_section') ): ?>
<php while ( has_sub_field('summary_section') ): ?>
<div class='summary-data'>
<?php the_sub_field('bulletin_summary'); ?>
<?php the_sub_field('location'); ?>
<?php the_sub_field('report_number'); ?>
<?php the_sub_field('incident_date'); ?>
<?php the_sub_field('incident_time'); ?>
</div>
<php endwhile; ?>
<?php endif; ?>
</div>
Somehow I solved this. I read through the info on the repeater plugin page again and modified my code. Didn’t see any obvious changes, but this snippet is working now.
<?php if(get_field('summary_section')): ?>
<div class="section-head"><h2>Summary</h2></div>
<?php while(has_sub_field('summary_section')): ?>
<ul>
<li class="bulletin-data-item"><h3>Bulletin Summary</h3><?php the_sub_field('bulletin_summary'); ?></li>
<li class="bulletin-data-item"><h3>Location</h3><?php the_sub_field('location'); ?></li>
<li class="bulletin-data-item"><h3>Report Number</h3><?php the_sub_field('report_number'); ?></li>
<li class="bulletin-data-item"><h3>Incident Date</h3><?php the_sub_field('incident_date'); ?></li>
<li class="bulletin-data-item"><h3>Incident Time</h3><?php the_sub_field('incident_time'); ?></li>
</ul>
<?php endwhile; ?>
<?php endif; ?>
The topic ‘Getting repeater data to display’ is closed to new replies.
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.