Home › Forums › ACF PRO › Repeater Field Wrapper, Incrementing Class and IDs › Reply To: Repeater Field Wrapper, Incrementing Class and IDs
Hi @ericcarroll and @stinkykong
I’m honestly not sure what you’re trying to achieve here.. your descriptions are a bit confusing to be honest 🙂
But here’s what I think you’re saying.. You want to show the content within the each repeater.. you want to first check wether some content exists to avoid empty html wrapping elements. You want to increment the “id” of the gallery content for each gallery listed.
Here’s some sample code based on your own.
<?php $i = 0; ?>
<?php if( have_rows('manufacturing_grid_blocks') ): while ( have_rows('manufacturing_grid_blocks') ) : the_row(); ?>
<div class="small-12 medium-4 large-4 columns grid-block">
<?php if( get_sub_field('manufacturing_grid_media') ): ?>
<img src="<?php the_sub_field('manufacturing_grid_photo'); ?>" />
<?php endif; ?>
<?php the_sub_field('manufacturing_grid_video'); ?>
<h3><?php the_sub_field('manufacturing_grid_header'); ?> <span><?php the_sub_field('manufacturing_grid_sub_header'); ?></span></h3>
<?php if( get_sub_field('manufacturing_grid_content') ): ?>
<p><?php the_sub_field('manufacturing_grid_content'); ?></p>
<?php endif; ?>
<!-- If images are added to gallery, show Photos link and open gallery in modal -->
<!-- Add integer after ID -->
<?php if( get_sub_field('manufacturing_grid_gallery') ): ?>
<a href="#" data-reveal-id="manufacuring-gallery-<?php echo $i; ?>">View Photos</a>
<div id="manufacuring-gallery-<?php echo $i; ?>" class="reveal-modal" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<?php the_sub_field('manufacturing_grid_gallery'); ?>
</div>
<?php $i++; //Only increment if we had a gallery.. move this outside the last div but inside endwhile if you want it to increment regardless ?>
<?php endif; ?>
</div>
<?php endwhile; endif; ?>
@stinkykong I can’t see anything wrong with your code.. what is it that’s not working according to what you expect?
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.