Home Forums ACF PRO if (have_rows()) not working


if (have_rows()) not working

  • I was seeing this issue. If I grab my repeater and output it raw it’s showing an empty array but have_rows() was returning true. I think it was just the result of my data and fields changing a number of times during development. Re-saving all the pages seemed to fix it.

  • I’m having the same issue as someone else in here.

    I have an options page with some fields that I want to display on the front-end of my website.

    When I use if ( have_rows('my_repeater', 'options') ) { nothing is returned.

    When I use get_field('my_repeater', 'options'), the only thing being returned is the number of rows.

    Has this issue been looked into yet?

  • I am having a similar problem with have_rows not working on a repeater field.

    I am using ACF Pro 5.7.7.

    Is this still an open issue being looked at ?

  • @tulip I had a similar issue which was caused by have_rows() running too early in my code. Ensure that it’s after WP has loaded the plugins and it should hopefully fix it.

  • @swennet So I’m not sure if it’s a typo, but when retrieving a value from an options page, you use ‘option’ (singular), not ‘options’ (plural).

    Also, the if statement will only return true or false. You need to loop through them and load the row’s data (the_row();) per loop iteration.

    So your code would look something similar to:

    if ( have_rows('my_repeater', 'option') ) : 
    	//Use while loop to loop through rows, the_row() will load the row's data
    	while( have_rows('my_repeater', 'option') ) : the_row();
    		// create variables for sub field values
    		$sub_field = get_sub_field('sub_field');
    	<li><?php echo $sub_field; ?></li>
    	<?php endwhile; ?>
    <?php endif; ?>
  • Same issue here. The get_field() and have_rows() only working create repeater by UI. Not working creating repeater by acf_add_local_field_group(). Any idea?

  • The same problem … did anyone find a solution?

Viewing 7 posts - 26 through 32 (of 32 total)

The topic ‘if (have_rows()) not working’ is closed to new replies.