Home Forums Add-ons Repeater Field How to group sub fields? Reply To: How to group sub fields?

  • OK so it’s probably more a regular coding issue than an ACF one but would still be grateful for any suggestions on best way to approach working with rows of sub fields which can be handled in groups (for formatting etc). Multidimensional array maybe?

    $name = get_sub_field(‘name’); // John Joan Ravi Devi Olaf Freya
    $fruit = get_sub_field(‘fruit’); // apples oranges apples mangoes oranges apples
    $when = get_sub_field(‘when’); // breakfast breakfast lunch dinner breakfast lunch

    To get this (could be grouped either by fruit or time):

    John likes apples at breakfast
    Ravi likes apples at lunch
    Freya likes apples at lunch

    Joan likes oranges at breakfast
    Olaf likes oranges at breakfast

    Devi likes mangoes at dinner