How to display latest 4 entries (rows) using ACF Repeater?

Welcome.

There is a standard conclusion:
<?php if( have_rows('clients') ): ?>

 <?php while( have_rows('clients') ): the_row(); 

 // vars
 $link1 = get_sub_field('clients_link');
 $link2 = get_sub_field('clients_site');
?>

 <div class="client-block-info">
the content
</div>

 <?php endwhile; ?>

<?php endif; ?>


Tell me how to get the last 4 records (rows).

Thank you!
April 19th 20 at 12:21
1 answer
April 19th 20 at 12:23
Increment
Thanks, but in php I am not strong. Can help in my example? - Name_Lark commented on April 19th 20 at 12:26
@Name_Lark,

something like that

if( have_rows('clients') ) {
 $x=0; 
 while ($x<4) {
 $x++; 
 while( have_rows('clients') ) { 
 the_row(); 
 // the content
}
}
}
- Ethyl_Simonis commented on April 19th 20 at 12:29
@Ethyl_Simonis, I've done it. Displays the first 4, not the last. - Name_Lark commented on April 19th 20 at 12:32
@Name_Lark, official documentation

easy solution - Ethyl_Simonis commented on April 19th 20 at 12:35
@Ethyl_Simonis, simple solution - and did so. Displays the first 4 in reverse order.
official documentation - I Will try. - Name_Lark commented on April 19th 20 at 12:38

Find more questions by tags WordPress