I am trying to create a gallery.
1. I register fields via PHP
acf_add_local_field_group(array(
'key' => 'group_post_gallery',
'title' => esc_html__( 'Gallery', 'lilio' ),
'fields' => array(
array(
'key' => 'field_post_gallery',
'label' => esc_html__( 'Images', 'lilio' ),
'name' => 'my_post_gallery',
'type' => 'gallery',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'min' => '',
'max' => '',
'insert' => 'append',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
array(
'param' => 'post_format',
'operator' => '==',
'value' => 'gallery',
),
),
),
'menu_order' => 0,
'position' => 'acf_after_title',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
2. Added code from https://www.advancedcustomfields.com/resources/gallery/ > Basic list of images
<?php
$images = get_field('gallery');
$size = 'full'; // (thumbnail, medium, large, full or custom size)
if( $images ): ?>
<ul>
<?php foreach( $images as $image ): ?>
<li>
<?php echo wp_get_attachment_image( $image['ID'], $size ); ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Errors:
Warning: Illegal string offset ‘ID’ in …
What is wrong ?