Skip to content

Instantly share code, notes, and snippets.

@hakikz
Created March 23, 2021 19:21
Show Gist options
  • Save hakikz/7132e4f9b9362ef651bd1452b7804622 to your computer and use it in GitHub Desktop.
Save hakikz/7132e4f9b9362ef651bd1452b7804622 to your computer and use it in GitHub Desktop.
BS Carousel For WP with ACF
<!-- Carousel -->
<div id="carouselHero" class="carousel slide carousel-fade" data-ride="carousel" data-pause="false">
<?php if( have_rows('carousel') ): $id = 0 ?>
<div class="carousel-inner">
<?php while( have_rows('carousel') ): the_row(); $id++ ?>
<div class="carousel-item <?php if($id == 1): echo "active"; endif; ?>">
<div class="content-wrap">
<?php
$logo = get_sub_field('logo');
$title = get_sub_field('title');
$subtitle = get_sub_field('subtitle');
$description = get_sub_field('description');
?>
<?php if (!empty($logo)): ?>
<img src="<?php echo get_sub_field('logo'); ?>" alt="Logo" class="img-fluid logo">
<?php else: ?>
<img src="">
<?php endif; ?>
<?php if (!empty($title)): ?>
<h1><?php echo get_sub_field('title', false, false); ?></h1>
<?php else: ?>
<h1>&nbsp;</h1>
<?php endif; ?>
<?php if (!empty($subtitle)): ?>
<h4><?php echo get_sub_field('subtitle'); ?></h4>
<?php else: ?>
<h4>&nbsp;</h4>
<?php endif; ?>
<?php if (!empty($description)): ?>
<p><?php echo get_sub_field('description'); ?></p>
<?php else: ?>
<p>&nbsp;</p>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<!-- Arrows -->
<!-- <a class="carousel-control-prev" href="#carouselHero" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselHero" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a> -->
<!-- Arrows -->
</div>
<!-- /.Carousel -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment