Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created January 7, 2014 22:11
Show Gist options
  • Save jaredatch/8307866 to your computer and use it in GitHub Desktop.
Save jaredatch/8307866 to your computer and use it in GitHub Desktop.
Generate slideshow from ACF gallery field via Soliloquy Dynamic addon
<?php
/**
* Generate slideshow from ACF gallery field.
*
* A Flexslider (Soliloquy) slider will be created from from images assigned
* via the ACF gallery field type.
*
* The following plugins are needed:
* - Soliloquy
* - Soliloquy Dyanmic Addon
* - Soliloquy Crop Addon (for thumbnails only)
*
* For information and arguments available for the Dynamic addon are at:
* http://soliloquywp.com/docs/dynamic-addon/
*
* @since 1.0.0
*/
function ja_gallery() {
$images = get_post_meta( get_the_ID(), '_ja_property_images', true );
if ( $images ) {
$ids = '';
$x = 1;
foreach( $images as $id ) {
if ( $x == 1 ) {
$ids .= $id;
} else {
$ids .= ',' . $id;
}
$x++;
}
echo '<div class="property-slideshow">';
soliloquy_dynamic( array(
'preloader' => 'true',
'animate' => 'false',
'id' => 'custom-random-images',
'images' => $ids,
'link' => 'file',
'size' => 'gallery',
'width' => '400',
'height' => '250',
'thumbnails' => 'true',
'thumbnails_crop' => 'true',
'thumbnails_width' => '100',
'thumbnails_height' => '75',
'thumbnails_min' => '4',
'thumbnails_distance' => '10'
) );
echo '</div>';
}
}
add_action( 'genesis_entry_content', 'ja_gallery' );
@jemoreto
Copy link

Great! Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment