How to Get the First Row of a Repeater Field in ACF

Are you looking to retrieve the first row of a repeater field in ACF (Advanced Custom Fields)? In this article, I will guide you through the process.

Get the First Row of a Repeater Field in ACF

To obtain the first row within a repeater field, you need to include the get_row_index() function inside your while loop. Here’s an example using a testimonials repeater field:

if (have_rows('testimonials')) : 
	the_row();
	while (have_rows('testimonials')) : 
		the_row();
		if (get_row_index() == 1) {
			// This is the first row of the ACF repeater field
		} 

		// Place your code for other rows of the repeater here
	endwhile;
endif;

By following these steps, you will be able to retrieve the first row of a repeater field in ACF. I hope this article provides you with an easy solution for accessing the initial row of a repeater when developing custom WordPress websites using ACF. You may also want to check out my other tutorials.

Rizwan Aritonang

An independent WordPress & Front-End Developer from Bandung, Indonesia.

Get In Touch

Leave a Comment