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:
<?php
if ( have_rows('my_repeater', 'option') ) :
?>
<ul>
<?php
//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; ?>
</ul>
<?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 topic ‘if (have_rows()) not working’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.