Support

Account

Home Forums Add-ons Repeater Field First row of repeater field that returns Image Object Reply To: First row of repeater field that returns Image Object

  • That worked! Thank you! My code may not be as elegant as it should be. Here is what I did:

    <?php if( have_rows('slider') ): ?>
    
    		<?php while( have_rows('slider') ): the_row(); 
        
                $image = get_sub_field('slide');
                $rows = get_field('slider', false, false); // get all the rows
                $first_row = $rows[0]; // get the first row
                $first_row_image = $first_row['slide']; // get the sub field value 
        
                ?>
    
    			<div class="mobile-bg visible-xs" style="background-image:<?php echo $image['url']; ?>"></div><!-- end mobile-bg -->
    			<?php break; ?>
    
    		<?php endwhile; ?>
        
        <?php endif; ?>

    I am open to suggestions to make my code better.

    Thanks again!