Home Forums Add-ons Repeater Field Repeater field empty


Repeater field empty

  • If added a repeater field. But when I try to implement it, it returns empty.
    I’ve tried to var_dump it. But I get a “bool(false)”.

      if( have_rows('lookbook_album') ):
      while( have_rows('lookbook_album') ): the_row(); 
    // vars
    $image = get_sub_field('lookbook_slider_image');
    $description = get_sub_field('lookbook_description');
    $products_sku = get_sub_field('products_sku');
    <div class="lookbook">
    	<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
        <?php echo $description; ?>
    	<?php echo $products_sku; ?>
    <?php endwhile; endif; ?>
  • Hi @rolf-databoss ,

    Thanks a lot for reaching out to us.

    Kindly ensure that you have correctly set the location settings to allow the repeater load inside the current posts/page.

    Let me know how it goes

  • Hi @acf-support,

    I think I’ve set it correctly because I can fill it in the admin side in the custom post type I’ve created.

    There’s no problem when I save the post and I see the changes in the admin.

    It’s just that I can’t get the content in the front-end.

  • Hi @rolf-databoss

    Could you please make sure if you put the code inside The Loop? The issue you had probably occurred because you were trying to execute the have_rows() function outside of The Loop. To fix it, you need to pass the post/page ID as the second parameter to the have_rows() function like this:

    have_rows(‘lookbook_album’, 99)

    Where “99” is the post/page ID where the custom field is assigned. This page should give you more idea about it:

    If that doesn’t help, could you please try to debug the value like the following?

    var_dump(get_field('lookbook_album', 99));

    Thanks 🙂

  • Hi @acf-support,

    I did a var_dump including the page is. It was already in the loop. But the only thing I get back in the var_dump get_field is:
    string(1) “2”

    But in var_dump have_rows including the post id I still get:

  • Hi @rolf-databoss

    That’s weird. The var_dump(get_field('lookbook_album', 99)); code should show the repeater values with all of its rows, not only the total row count. Maybe there’s a function in your plugin or theme that causes this issue. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Sixteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    If the issue persists, could you please share the JSON or XML export of your field group so I can test it out on my end?

    Thanks 🙂

  • I’ve found the problem. In my theme if got an offset. And that conflicted with the repeater field.

    This is the offset I used. I made an adjustment to is so it only works on the index.

    /* offset the default wordpress loop with 3 items */
    add_action('pre_get_posts', 'myprefix_query_offset', 1 );
    function myprefix_query_offset(&$query) {
        if ( !$query->is_home() ) {
    	    $offset = 3;
    	    $ppp = get_option('posts_per_page');
    	    if ( $query->is_paged ) {
    	        $page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
    	        $query->set('offset', $page_offset );
    	    else {
    add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
    function myprefix_adjust_offset_pagination($found_posts, $query) {
        //Define our offset again...
        $offset = 3;
        //Ensure we're modifying the right query object...
        if ( $query->is_home() ) {
            //Reduce WordPress's found_posts count by the offset... 
            return $found_posts - $offset;
        return $found_posts;
  • Hi @rolf-databoss

    Glad you found the issue. I believe you can also check if the query is for the ‘acf-field’ or ‘acf-field-group’ post types if you use the PRO version, and ‘acf’ post type if you use the free version.

    Hope this helps 🙂

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

The topic ‘Repeater field empty’ is closed to new replies.