Home Forums Add-ons Repeater Field Get all Fields & Sub Fields of a POST ( Repeater)


Get all Fields & Sub Fields of a POST ( Repeater)

  • Hi,

    Is there a way to list all sub fields ( field name, field meta_key, field meta_values and field_key) in a repeater field of a post and also check if repeater sub field also has another repeater field etc…?

  • If you want to return all the fields of a field group you can use

    $fields = acf_get_fields($group_key);

    if you want to get all the field groups for a post

    $groups = acf_get_field_groups(array('post_id' => $post_id));

    putting them together

    $groups = acf_get_field_groups(array('post_id' => $post_id));
    if ($groups) {
      foreach ($groups as $index => $group) {
        $groups[$index]['fields'] = acf_get_fields($group['key']);
    echo '<pre>'; print_r($groups); echo '<pre>';
  • This reply has been marked as private.
  • Repeaters are saved in multiple db entires. The meta_key for the repeater holds the number of rows. Each subfield is saved at “{$repeater}_{$row}_{$sub_fieeld}”

    There isn’t any page where you can find all ACF functions. The 2 functions that I posted are internal function used by ACF and not something that most people would use. They are functions that I know are there because I have spent several years digging around in the ACF code to not only know how it works but to build things that alter the way ACF functions.

    There isn’t any way to get all of the fields of a specific type other than to know what fields you want to get. ACF does not even know what type of field is being called until it matches a field name up with a field key and gets the field object. I suppose you could build additional functionality that does this, but there’s nothing built in that will do it for you.

  • Thank you soo much for your help 🙂

    It really help me alot.

  • The functions you have mention in your code not working with the free version of ACF only work with ACF Pro ?

  • Yes, the functions are in ACF5. In ACF4 the same things can be accomplished using filters. For example

    $field_groups = apply_filters('acf/get_field_groups', array());

    Unfortunately, I have not used these in a very long time.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Get all Fields & Sub Fields of a POST ( Repeater)’ is closed to new replies.