Last active
September 19, 2017 19:19
-
-
Save keeneyemedia/315744e5db40e655c506 to your computer and use it in GitHub Desktop.
[ACF Random Gallery Post - Step 3] #tutorials #acf_random_gallery
This file contains 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
//Set the random gallery we just selected to the $images variable. | |
$images = get_field('gallery_images', $other_page); | |
//Begin our ACF loop | |
if( $images ): | |
//We want to only show 6 images, so lets begin a count | |
$photocount = 0; ?> | |
<ul class="galleries"> | |
<?php | |
//Break the array into each image | |
foreach( $images as $image ): ?> | |
<?php | |
//Bump up our counter on each image | |
$photocount++; | |
//Make sure we're still at or under 6 images before continuing | |
if($photocount <= 6) { ?> | |
<li> | |
<a href="<?php echo $image['sizes']['large']; ?>" rel="prettyPhoto[<?php echo $post->post_name; ?>]" title="<?php echo $image['caption']; ?>"> | |
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" title="<?php echo $image['title']; ?>" class="gallery-thumbnail" /> | |
</a> | |
</li> | |
<?php } | |
endforeach; ?> | |
</ul> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment