Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@PurpleHippoDesign
Last active January 27, 2017 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PurpleHippoDesign/c5f8c7e1767de856bcba to your computer and use it in GitHub Desktop.
Save PurpleHippoDesign/c5f8c7e1767de856bcba to your computer and use it in GitHub Desktop.
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