Last updated Oct 19, 2022


This function is deprecated. Please use the have_rows() function instead.

This function is used within a while-loop to loop through each row of a repeater field.

Unlike have_rows(), this function will take a step through the available rows each time it is called, causing undesired results when also used within an if-statment.


the_repeater_field( $field_name, $post_id );
  • $field_name (string) (Required) The name of the Repeater field to be retrieved. e.g. ‘gallery_images’
  • $post_id (mixed) (Optional) The post ID where the value is saved. Defaults to the current post.


(bool) True if a row exists.

Change Log

  • Deprecated in version 3.3.4
  • Added in version 2.0.3



Loop through Repeater field

This example demonstrates how to loop through a repeater field called “gallery_images”.

<?php if( get_field('gallery_images') ): ?>
    <?php while( the_repeater_field('gallery_images') ): ?>
        <img src="<?php the_sub_field('image'); ?>" alt="<?php the_sub_field('alt'); ?>" />
    <?php endwhile; ?>
 <?php endif; ?>

Loop through Repeater field from another post

This example demonstrates looping through a Repeater field from a different post with the ID of 123.

Note: You don’t need to specify the $post_id for any sub field functions.

if( get_field('repeater_field_name', 123) ) {
    echo '<ul>';
    while( the_repeater_field('repeater_field_name', 123) ) {
        echo '<li>sub_field_1 = ' . get_sub_field('sub_field_1') . ', sub_field_2 = ' . get_sub_field('sub_field_2') .', etc</li>';
    echo '</ul>';