Last active
August 29, 2015 13:57
-
-
Save yellowberri-snippets/9768750 to your computer and use it in GitHub Desktop.
PHP: ACF: Repeater Field to Image Gallery or Flex Slider
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
<?php | |
// ACF Repeater Field to Flex Slider. | |
$repeaterFieldName = 'history_gallery'; | |
$pageId = NULL; // Just in case, use only if needed. | |
$imageFieldName = 'image'; | |
$imageSize = 'medium'; | |
$repeater = get_field($repeaterFieldName, $pageId); | |
?> | |
<?php if ($repeater) : ?> | |
<ul class="images"> | |
<?php foreach ($repeater as $slide) : ?> | |
<?php | |
$slideImage = $slide[$imageFieldName]; | |
$slideUrl = $slide[$imageFieldName]['url']; | |
$slideImage = $slideImage['sizes'][$imageSize]; | |
?> | |
<li> | |
<a href="<?php echo $slideUrl; ?>"> | |
<img src="<?php echo $slideImage; ?>"> | |
</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