Home › Forums › Add-ons › Repeater Field › Repeater row count for nested gallery sub field rel attribute › Reply To: Repeater row count for nested gallery sub field rel attribute
Hi @inhouse
Well it’s not technically an ACF question (more of PHP) but we’ll be glad to help you none the less!
If I understand you correctly this should do it:
<?php if( have_rows('portfolio_category') ): ?>
<ul class="no-bullet-list photo-gallery-category-list">
<?php $i = 1; ?>
<?php while( have_rows('portfolio_category') ): the_row(); ?>
<li class="portfolio-gallery-category">
<h3><?php echo get_sub_field('portfolio_category_title'); ?></h3>
<?php $portfolio_images = get_sub_field('portfolio_gallery');
if( $portfolio_images ): ?>
<ul class="photo-gallery">
<?php foreach( $portfolio_images as $image ): ?>
<li class="photo">
<a class="fancybox-thumb" rel="fancybox-thumb-<?php echo $i; ?>" href="<?php echo $image['url'] ?>" title="<?php echo $image['caption']; ?>">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>"/>
</a>
</li><!--photo-->
<?php endforeach; ?>
</ul><!--photo-gallery-->
<?php wp_reset_postdata();
endif; ?>
</li><!--portfolio-gallery-category-->
<div class="clr"></div>
<?php $i++; endwhile; ?>
</ul><!--gallery-->
<?php endif; ?>
I have a feeling you overcomplicated it in your head.
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.