Support

Account

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?