Created
July 28, 2014 05:49
-
-
Save ZellSnippets/20d04217571b7c1fc4ce to your computer and use it in GitHub Desktop.
PHP:ACF:Repeater
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
Advanced Custom Fields | |
// Repeater | |
have_rows('repeater_field_name') | |
get_sub_field('sub_field_name') | |
the_sub_field('') | |
// Usage | |
<?php if( have_rows('repeater_field_name') ): ?> | |
<ul class="slides"> | |
<?php while( have_rows('repeater_field_name') ): the_row(); | |
// vars | |
$image = get_sub_field('image'); | |
$content = get_sub_field('content'); | |
$link = get_sub_field('link'); | |
?> | |
<li class="slide"> | |
<?php if( $link ): ?> | |
<a href="<?php echo $link; ?>"> | |
<?php endif; ?> | |
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" /> | |
<?php if( $link ): ?> | |
</a> | |
<?php endif; ?> | |
<?php echo $content; ?> | |
</li> | |
<?php endwhile; ?> | |
</ul> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment