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; // 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.
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!