Support

Account

Home Forums Add-ons Repeater Field Random repeated field and get repeated list of images inside

Solving

Random repeated field and get repeated list of images inside

  • Hello

    I have a gallery that I created through the repeated field. In each repeated fields I have another repeated field that contains a list of images and description to them.

    What I want and what I need to do: I need to get random repeated field of top level (Photo album) and get access to inside repeated list (Images list and description to them) to all fields in inner repeated

    <?php if( have_rows('albums', 140) ): ?>
    <!-- begin mediablock  -->
    <div class="mediablock widget">
    <h3 class="title title--blue">Gallery</h3>
    <?php 
    $rows = get_field('albums', 140);
    $row_count = count($rows);
    $i = rand(0, $row_count - 1);
    ?>
    
    <!-- begin simpleblock  -->
    <div class="simpleblock">
    <?php 
    if( have_rows('photo_and_description', 140) ):
    	while ( have_rows('photo_and_description', 140) ) : $rows[ $i ] ?>
    <img src="<?php echo $rows[ $i ]['photo']; ?>" alt="" />
    <p class="simpleblock__text"><?php echo $rows[ $i ]['description']; ?></p>
    <?php endwhile;
    	else :
    endif; ?>
    </div>
    <!-- end simpleblock -->
    
    </div>
    <!-- end mediablock -->
    <?php
    else :
    endif; ?>
  • No any idea how to get random repeated field and access to nested repeated fields?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.