Create a FooBox gallery that launches form a single button
<?php
/*
uses: acf gallery field
launches gallery from single button
*/
function service_gallery() {
global $post;
$photos = get_field( 'gallery' );
if( empty( $photos ) )
return;
$output = '';
// print out all the photo links
foreach( $photos as $key => $photo ) {
$button = '';
$class = '';
if ( !$key ) {
// We are at the first element
$button = '<span class="view-gallery">View Gallery</span>';
$class = ' gallery button';
}
$attachment_id = $photo['ID'];
$lightbox = wp_get_attachment_image_src( $attachment_id, 'lightbox', array() );
$output .= sprintf( '<a href="%s" class="foobox%s" rel="gallery-%s" title="%s">%s</a>', $lightbox[0], $class, get_the_ID(), esc_html( $photo['caption'] ), $button );
}
return $output;
}