Skip to content

Instantly share code, notes, and snippets.

@webgurus
Last active September 7, 2020 10:39
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save webgurus/6420102 to your computer and use it in GitHub Desktop.
Save webgurus/6420102 to your computer and use it in GitHub Desktop.
Root's bootstrap slider example with Advanced Custom Fields Gallery plugin.
<?php
/* SLIDER CUSTOM FIELD FOR HOMEPAGE */
$images = get_field('slider_photos');
$count=0;
$count1=0;
if($images) : ?>
<div id="slider">
<div id="carousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<?php foreach( $images as $image ): ?>
<li data-target="#carousel" data-slide-to="<?php echo $count; ?>" <?php if($count==0) : ?>class="active"<?php endif; ?>></li>
<?php
$count++;
endforeach; ?>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php foreach( $images as $image ): ?>
<div class="item<?php if($count1==0) : echo ' active'; endif; ?>">
<img src="<?php echo $image['sizes']['slider-img']; ?>" alt="<?php echo $image['alt']; ?>" />
</div><!-- item -->
<?php
$count1++;
endforeach;
?>
</div><!-- carousel inner -->
</div><!-- #carousel -->
</div><!--#slider-->
<?php endif; ?>
@knjasper
Copy link

knjasper commented Feb 6, 2016

Nice work here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment