When using ACF (Advanced Custom Fields) repeater fields, the markup should look like this to initiate the loop.
<? if( have_rows('my-repeating-field) ): ?>
<? endif ?>
However, I would like to make this dynamic, meaning I use another PHP variable as part of the if() code, something like as follows:
<? $variable = get_field('my-variable-field'); ?>
<? if( have_rows("'" . $variable . "-repeating-field" . "'") ): ?>
<? endif ?>
However, this is not working. Is there a way I can do this with ACF/PHP? Seems pretty simple to me?
$variablehas any value or not? you can try$row_field = $variable . '-repeating-field';and then usevar_dumpto check if it has corrected value or not. then if it is correct tryif(have_rows($row_field)...have_rows($variable . '-repeating-field')should be enough