CMB2の反復可能なファイルリストグループ内に入力された画像を作成/アクセスする方法の例をどこでも探しています。私が見つけることができるすべての例は、単一の画像のみです。リンクは次のとおりですhttps://github.com/CMB2/CMB2/wiki/Field-Types#group
MY CODE:
// creating a group
$group_field_id = $bautage->add_field( array(
id' => 'tagen_entries',
'type' => 'group',
'description' => __( 'Tagen', 'cmb2' ),
'repeatable' => true,
'options' => array(
'group_title' => __( 'Tagen {#}', 'cmb2' ), // since version 1.1.4, {#} gets replaced by row number
'add_button' => __( 'Add Another Entry', 'cmb2' ),
'remove_button' => __( 'Remove Entry', 'cmb2' ),
'sortable' => true,
),
) );
// creating repeatable fields
$bautage->add_group_field( $group_field_id, array(
'name' => 'Tag Name',
'id' => 'tag_name',
'type' => 'text',
) );
$bautage->add_group_field( $group_field_id, array(
'name' => 'Tage Photos',
'id' => 'tage_photos',
'type' => 'file_list',
) );
// page code
$tagen_entries = get_post_meta( get_the_ID(), 'tagen_entries', true );
foreach ( (array) $tagen_entries as $key => $entry ) {
if ( isset( $entry['tag_name'] ) ) {
$tag_name = esc_html( $entry['tag_name'] );
echo $tag_name;
}
if ( isset( $entry['tage_bildern'] ) ) {
// loop to bring all the photos
// also need the first photo from each entry to be used as a click trigger to open the slideshow
}
}