Support

Account

Home Forums Add-ons Repeater Field Question about conditional branch with Repeater Field Reply To: Question about conditional branch with Repeater Field

  • Hi,elliot.

    I couldn’t get result with what I posted.
    But finally I could get good result with below code.

    Thank you for your comment.

    <?php
    $gallery = get_field('gallery' ); // get all the rows
    $gallery_items = $gallery[0]; // get the first row
    $gallery_item = $gallery_items['gallery_photo']; // get the sub field value 
    if($gallery_item):
    ?>
    <div class="box">
    <h3><img src="images/images.png" /></h3>
    <div id="gallery" class="ad-gallery">
    <div class="ad-image-wrapper"></div>
    <div class="ad-nav">
    <div class="ad-thumbs">
    <ul class="ad-thumb-list">
    <?php while(has_sub_field('gallery')): ?>
    <?php
    $image = wp_get_attachment_image_src(get_sub_field('gallery_photo'), 'large');
    $thumb = wp_get_attachment_image_src(get_sub_field('gallery_photo'), 'thumbnail');
    ?>
    <li><a href="<?php echo $image[0] ?>"><img src="<?php echo $thumb[0] ?>"></a></li>
    <?php endwhile; ?>
    </ul>
    </div>
    </div>
    </div>
    </div>
    <?php endif; ?>