Created
December 4, 2015 18:07
-
-
Save ericakfranz/48e1d15856de40cd2b5b to your computer and use it in GitHub Desktop.
Get the IDs of all images attached to a post via ACF gallery field, and output to an Envira Gallery using the Dynamic Addon
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 | |
$gallery = get_post_meta( get_the_ID(), 'gallery_images' ); // 'gallery_images' is name of the ACF gallery field | |
$post_id = get_the_ID(); // grab the ID of the post to build into our Dynamic gallery's custom ID | |
// If we have something output the gallery | |
if( isset( $gallery[0] ) && is_array( $gallery[0] )) { | |
$image_ids = $gallery[0]; | |
envira_dynamic( array( | |
'id' => 'post-gallery-' . $post_id . '', | |
'images'=> implode( ',', $image_ids ), | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment