Support

Account

Home Forums General Issues Get rows from repeater EXCEPT first

Solved

Get rows from repeater EXCEPT first

  • Hi folks,

    I am using cycle2 and progressive loading which requires you show the first image, then ajax load in the rest as you click. I can get the first row of the repeater no problem, and then easily loop through all the images of the repeater, but of course this would mean that the first image is included twice. So, is there any way when calling the repeater rows, to ignore/remove the first row?

    This is what I have so far:

    <?php $rows = get_field('publication_images', 148); // get all the rows
    $first_row = $rows[0]; // get the first row
    $first_row_image = $first_row['publication_each_image' ]; // get the sub field value 
    $image = wp_get_attachment_image_src( $first_row_image, 'slider');?>
    										<div class="each-slide">
        <img src="<?php echo $image[0]; ?>" />
    </div>
    										<script id="product-slides" type="text/cycle" data-cycle-split="---">
        <?php while ( have_rows('publication_images', 148) ) : the_row(); ?>
        <div class="each-slide">
            <?php echo wp_get_attachment_image(get_sub_field('publication_each_image', 148), 'slider' ); ?>
        </div>										    ---
        <?php endwhile; ?>										</script>
  • I thought this would’ve worked… but doesn’t seem to do anything.

    <?php $i = 0; while ( have_rows(‘publication_images’, 148) ) : $i++; if ($i != 1) : the_row(); ?>
    <div class=”each-slide”>
    <?php echo wp_get_attachment_image(get_sub_field(‘publication_each_image’, 148), ‘slider’ ); ?>
    </div>

    <?php endif; endwhile; ?>

  • <?php $i = 0; while ( have_rows('publication_images', 148) ) : the_row(); $i++; if ($i != 1) : ?>
    											<div class="each-slide">
    										        <?php echo wp_get_attachment_image(get_sub_field('publication_each_image', 148), 'slider' ); ?>
    										    </div>
    										    ---
    										<?php endif; endwhile; ?>
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Get rows from repeater EXCEPT first’ is closed to new replies.