Support

Account

Home Forums General Issues Load default value for gallery field Reply To: Load default value for gallery field

  • And I just solved it myself. You need to create an array and fill it with each and every file’s ID, off you go:

    function default_photos( $field_photos ) {
    		
        $photos = get_field('artist_photos', 'option');
    	
    	$array = array();
    
    	foreach ($photos as $photo) {
    		$id = $photo['ID'];
    		array_push($array, $id);
    	};
    		
         $field_photos['default_value'] = $array;
         return $field_photos;
    		 
    }
    
    add_filter('acf/load_field/name=press_photos', 'default_photos');