Home › Forums › ACF PRO › if (have_rows()) not working › Reply To: if (have_rows()) not working
Same here!
I notice a recent behaviour change, that probably happened with the latest ACF Pro update.
On WordPress instances where I used Repeater Fields with this type of code:
if( have_rows('acf_repeater_field') ):
while ( have_rows('acf_repeater_field') ) : the_row();
// OUTPUT
endwhile;
endif;
Until now, when no fields where present, there was no output.
What I see now: even when there are no fields, there’s an output – html markup is generated. If I dump the raw content of the acf_repeater_field, I see a NULL array.
So my quick fix is to surround the whole block of code with something like:
$acf_repeater_field = get_field('acf_repeater_field');
if ( !empty( $acf_repeater_field ) ) :
// ETC
endif;
Any explanation for this behavior? Is it indeed a change in ACF?
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.