function display_image_gallery_shortcode($atts) {
// Set up default attributes for the shortcode
$atts = shortcode_atts(
array(
'pod_name' => 'dogs', // Replace with your actual pod name
'field_name' => 'dog_gallery', // Replace with your actual image field name
),
$atts,
'image_gallery'
);
// Get the Pod
$gallery = pods($atts['pod_name']);
// Start the output buffer to return the HTML
ob_start();
// Check if there are any items in the Pod
if ($gallery->total() > 0) {
// Start the gallery container
echo '
';
// Loop through the Pod items
while ($gallery->fetch()) {
// Get the list of image URLs (space-separated)
$image_urls = $gallery->field($atts['field_name']);
// Split the string into an array of image URLs
$image_array = explode(' ', $image_urls); // Split by space
// Loop through the image array and display each image
foreach ($image_array as $image_url) {
// Display each image in a gallery item
echo '
';
}
}
// End the gallery container
echo '
';
}
// Return the gallery HTML
return ob_get_clean();
}
// Register the shortcode
add_shortcode('image_gallery', 'display_image_gallery_shortcode');