Support

Account

Home Forums Backend Issues (wp-admin) How do I get a site wide of list all ACF fields

Solved

How do I get a site wide of list all ACF fields

  • Hi,

    I’m just wondering if there is a simple way to get a list of all ACF fields on a site. I know that on a given post or page I can use the get_field_objects() function but that seems to only return fields for the current post.

    What I’m really after is just the field label, field name and field type any help would be appreciated.

    Thanks

  • Hi @jayokey

    There are undocumented functions that you can use get all the field groups and the custom fields associated with it. Could you please try the following code?

    $groups = acf_get_field_groups();
    foreach( $groups as $group ) {
        $fields = acf_get_fields($group);
        if($fields ) {
            foreach( $fields as $field ){
                echo 'Label: ' . $field['label'];
                echo "\n";
                echo 'Name: ' . $field['name'];
                echo "\n";
                echo 'Type: ' . $field['type'];
                echo "\n";
            }
        }
    }

    I hope this helps 🙂

  • Hi James,

    Thanks for your help. I changed the way I approached the problem and used the get_fields function so I didn’t have resort to using the undocumented function in the end.

    Cheers

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

You must be logged in to reply to this topic.