Skip to content

Instantly share code, notes, and snippets.

@ZellSnippets
Created July 28, 2014 05:49
Show Gist options
  • Save ZellSnippets/20d04217571b7c1fc4ce to your computer and use it in GitHub Desktop.
Save ZellSnippets/20d04217571b7c1fc4ce to your computer and use it in GitHub Desktop.
PHP:ACF:Repeater
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