Template Usage #
Specify the type as image inside the array key called type.
Note: the type should be lowercase string otherwise you will get error!
<?php
// Gallery field for multiple images upload
array(
'label' => esc_html__( 'Your Title', '' ),
'id' => "_your_id",
'type' => 'gallery', // specify the type field
'default' => '',
'conditional' => array()
)
?>
How to fetch the data? #
Use our function called tpmeta_gallery_field('_your_id')
 and pass the above array id key to fetch the metadata. Since the function tpmeta_gallery_field('_your_id')
will return the value as array of images so you have to echo the value inside a loop.Â
<?php
$tp_gallery_images = function_exists('tpmeta_gallery_field') ? tpmeta_gallery_field('gallery_meta_key') : ''; //tpmeta_gallery_field($string_ids, $size)
foreach($tp_gallery_images as $single_image_src){
echo $single_image_src['url'] ."<br>";
echo $single_image_src['alt'] ."<br>";
}
?>