Support

Account

Home Forums Front-end Issues Display all fields type (Array to string conversion problem)

Helping

Display all fields type (Array to string conversion problem)

  • Hello,

    I would like to display all type fields from my ACF field group (text, images, checkbox, wysiwyg, etc..). The problem is when i try to do this, i see Notice ” Array to string conversion” or “Undefined index:…..”. How can i do that?

    I try this but its not worked properly:

    
    $fields = get_field_objects();
    
    /* just for show arrays
    print '<pre>';
    print_r ($fields) ;
    print '</pre>'; 
    */
    
    if( $fields )
    {
    	ksort($fields);
    	foreach( $fields as $field_name => $field )
    	{
    		print '<div>';
    
    			print $field['label'];
    							
    			print '<img src="'.$field['value']['url'].'">';
    	
    			print $field['value']['0'];
    
     			print $field['value']['sizes'];
    
     			// etc....
    
    		print '</div>';
    	}
    }
    
    

    Please help me,
    Best regards, Luk

  • unless every field in an image field then you’ll need to check the type of each field and proceed accordingly to use the correct method to show what you’re looking for.

    Not all fields will have $field[‘value’][‘url’]

    and print $field[‘value’][‘sizes’] is an array, not really sure about print $field[‘value’][‘0’];

    If you just trying to see what’s in them try print_r() like your commented out code at the top.

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

The topic ‘Display all fields type (Array to string conversion problem)’ is closed to new replies.