Skip to content

Instantly share code, notes, and snippets.

@FernE97
Created May 9, 2013 23:45
Show Gist options
  • Save FernE97/5551466 to your computer and use it in GitHub Desktop.
Save FernE97/5551466 to your computer and use it in GitHub Desktop.
PHP: WordPress - Advanced Custom Fields Slider
<?php if ( get_field( 'slides' ) ) : // repeater field ?>
<ul class="slider">
<?php while ( the_repeater_field( 'slides' ) ) :
$image = get_sub_field( 'slide' ); // sub-field image ID
$slide = wp_get_attachment_image_src( $image, 'slides' );
$alt = get_post_meta( $image, '_wp_attachment_image_alt', true );
?>
<li><img src="<?php echo $slide[0]; ?>" alt="<?php echo $alt; ?>"></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment