This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists.


  • Deprecated in v3.3.4 – please replace with has_sub_field
  • Added in v2.0.3

This function is used in a “while loop” to loop through each row of  a repeater field.  This function requires the repeater field (activation code required).

This function will return either: the current row (continue loop) or false (end of loop).

Within the “while loop”, you can use these functions:


<?php the_repeater_field($field_name, $post_id); ?>
  • $field_name: the name of the repeater field to be retrieved. eg “gallery_images” (required)
  • $post_id: Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc


* Loop through a repeater field
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 a repeater field from another post
* - Note that the_sub_field and get_sub_field don't need a second parameter
$post_id = 123;
if( get_field('repeater_field_name', $post_id) )
    echo '<ul>';
    while( the_repeater_field('repeater_field_name', 5) )
        echo '<li>sub_field_1 = ' . get_sub_field('sub_field_1') . ', sub_field_2 = ' . get_sub_field('sub_field_2') .', etc</li>';
    echo '</ul>';
*  $post_id examples
$post_id = null; // current post
$post_id = 1;
$post_id = "option";
$post_id = "options"; // same as above
$post_id = "category_2"; // save to a specific category
$post_id = "event_3"; // save to a specific taxonomy (this tax is called "event")
$post_id = "user_1"; // save to user (user id = 1)

Related Documents