Home Forums General Issues How to get array of repeater field names and values?


How to get array of repeater field names and values?

  • Hi All,

    I have the following setup:

    – Option page with repeater field.
    – Custom Gutenberg blocks that will be created based on repeater values.

    I need to pass the data from the repeater to the blocks. The blocks takes following arguments when created:

    ['acf/custom-block-name', [
           'data' => [
            'name' => 'Field with name name',
            'category' => 'field with name category',

    When I try to get the repeater field values with get_field with get_field('acf_field_name', 'option', false) I get something like this:

    array (
      0 =>
      array (
        'field_5f6c94ef4bf62' => 'Repeater 1 name',
        'field_5f6c950451c89' => 'Repeater 1 category',
      1 =>
      array (
        'field_5f6c94ef4bf62' => 'Repeater 2 name',
        'field_5f6c950451c89' => 'Repeater 2 category',
      2 =>
      array (
        'field_5f6c94ef4bf62' => 'Repeater 3 name',
        'field_5f6c950451c89' => 'Repeater 3 category',

    It’s almost what I need, but the keys need to be ACF names ( ex. name ), not ACF keys ( ex. field_5f6c94ef4bf62 ).

    I tried get_field_object with mapping sub_fields and value keys, but with no success.

    Is there better way to get array of sub fields names => values ?

    Thanks in advance

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.