Support

Account

Home Forums Add-ons Repeater Field Query only first row in repeater

Helping

Query only first row in repeater

  • I would like to show only the first row of a repeater that is on another page. can someone help me with the code?

    here is my code so far

            <?php if (have_rows('version', 10081)): ?><?php while (have_rows('version', 10081)) : the_row(); ?>
                <div class="row row-download row-download<?php echo get_row_index(); ?>">
                    <div class="col-md-2">
                                  <?php the_sub_field('version_number'); ?>
            <?php endwhile; ?><?php endif; ?>

    Thanks!

  • <?php if (have_rows('version', 10081)): ?>
    
    	<?php $start = 1; $end = 1; ?> <!-- start and ending number -->
    
    	<?php while (have_rows('version', 10081)) : the_row(); ?>
    	
    	<?php if( $start <= $end ): ?> <!-- if start <= ending number, show -->
    		<div class="row row-download row-download<?php echo get_row_index(); ?>">
    		<div class="col-md-2">		
    		<?php the_sub_field('version_number'); ?>
    	<?php endif; ?>
    	
    	<?php $start++; ?> <!-- start + 1 -->
    	
    	<?php endwhile; ?>
    
    <?php endif; ?>

    Count your entries and only show the first entry.

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

The topic ‘Query only first row in repeater’ is closed to new replies.