Home Forums Front-end Issues Count single repeater field Reply To: Count single repeater field

  • the_sub_field() outputs the value, it does not return anything.

    Whether or not get_sub_field() causes an error it is still the function that you must use because you want to get the value and not display the value.

    get_sub_field() may return NULL or an empty value if the repeater has no rows. So you must get the field first and test it to see if it’s empty before performing any operation on the value

    $count = 0;
    $repeater_value = get_sub_field('footer_coloumn_spalten')) {
    if (!empty($repeater_value)) {
      $count = count($repeater_value);