Last active
January 27, 2017 11:09
-
-
Save PurpleHippoDesign/c5f8c7e1767de856bcba to your computer and use it in GitHub Desktop.
Generate slideshow from ACF gallery field via Soliloquy Dynamic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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