Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate slideshow from ACF gallery field via Soliloquy Dynamic
<?php
add_action( 'genesis_entry_content', 'pbh_do_post_content', 9 );
function pbh_do_post_content() {
echo '<div class="slider-container">';
// If at least 1 image is present in the Project Images Gallery field
if( $images = get_field('gallery') ) {
$image_ids = wp_list_pluck( $images, 'id' );
// Use thumbnails, only if we have more than 1 image
$use_thumbnails = ( 1 < count( $image_ids ) ? true : false );
// Soliloquy Dynamic requires image IDs to be passed as a comma separated list
$image_ids_string = implode( ',', $image_ids );
echo '<div class="gallery-slider">';
soliloquy_dynamic( array( 'id' => 'gallery-images', 'images' => $image_ids_string, 'thumbnails' => $use_thumbnails ));
echo '</div>';
}
echo '</div>';
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.