Support

Account

Home Forums Backend Issues (wp-admin) Getting ACF field ID's and labels

Helping

Getting ACF field ID's and labels

  • Hi,

    I’m trying to run a script in the Admin area that will output a list of all the ID’s and their labels. I’ve tried using this code:

    $fields = get_field_objects();
    
    if( $fields )
    {
    	foreach( $fields as $field_name => $field )
    	{
    		echo '<div>';
    			echo '<h3>' . $field['label'] . '</h3>';
    			echo $field['value'];
    		echo '</div>';
    	}
    }

    Which can be found here:
    http://www.advancedcustomfields.com/resources/get_field_objects/

    It seems to output the <h3> and <div> elements but with no content. Does anyone have any ideas about what I might be doing wrong?

  • Hi @kevleitch

    Where are you doing this? Remember that ACF attempts to use the global $post if you do not specify an ID (or options, user_id etc).

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

The topic ‘Getting ACF field ID's and labels’ is closed to new replies.