Home Forums ACF PRO Repeater Field not looping through the rows


Repeater Field not looping through the rows

  • Hi guys!

    I’m working in a project in which I need to loop several items using the repeater field, the thing is that have_rows and the_repeater_field functions are always returning false even if the repeater has values. This is a small piece of my code that tries to accomplish this.

    $postID = get_the_ID();
    $value = get_field('section_tiles', $postID);
    $tiles = array();
    if(get_field('section_tiles', $postID)):
      while(the_repeater_field('section_tiles', $postID)):
        $currentTile = array(
          "image" => get_sub_field('section_image'),
          "title" => get_sub_field('section_title'),
          "copy" => get_sub_field('section_copy'),
          "color" => get_sub_field('section_color'),
          "url" => get_sub_field('section_url')
        array_push($tiles, $currentTile);

    Here the variable $tiles is always an empty array at the end of the loop, but if I echo for instance the variable $value it prints out “3” which is the correct number of rows the repeater field has. So i don’t really know what’s going on, why the get_field(‘section_tiles’, $postID); function is returning the number of rows but the_repeater_field(‘section_tiles’, $postID) is returning false therefore is not looping (this also applies to the have_rows function)

    thank you!

  • Hi @dsalas

    I don’t think you can use the_repeater_field() function to loop a repeater field. Please check this page to learn how to use a repeater field:


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

You must be logged in to reply to this topic.