Last active
May 17, 2019 11:17
-
-
Save sarvar/152420aa1534561c3a4272df81381537 to your computer and use it in GitHub Desktop.
ACF Repeater field and Bootstrap Carousel
This file contains hidden or 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
<?php if( have_rows('feedbacks') ): ?> | |
<div class="carousel_bg"> | |
<div class="container"> | |
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> | |
<!-- Indicators --> | |
<ol class="carousel-indicators"> | |
<?php | |
$active = 'active'; | |
$num = 0; | |
while ( have_rows('feedbacks') ) : the_row(); | |
?> | |
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $num ?>" class="<?php echo $active ?>"></li> | |
<?php | |
$active = ''; | |
$num += 1; | |
endwhile; ?> | |
</ol> | |
<!-- Wrapper for slides --> | |
<div class="carousel-inner" role="listbox"> | |
<?php | |
$active = 'active'; | |
while ( have_rows('feedbacks') ) : the_row(); | |
?> | |
<div class="item <?php echo $active ?> screen08"> | |
<div class="container"> | |
<h1><?php the_sub_field('content'); ?></h1> | |
</div> | |
</div><!-- /item --> | |
<?php $active = ''; | |
endwhile; | |
?> | |
</div> | |
</div> | |
</div> | |
</div><!-- /row --> | |
<?php endif; ?> |
Hi Jay17231,
The solution is just to change <div class="item to <div class="carousel-item for BS4
Am trying to fetch from the custom post type "Carousel" with category_name, can you help on it??
<?php if( have_rows('carousel_slider') ): ?>
<div class="carousel_bg">
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<?php query_posts( array( 'post_type' => 'Carousel', 'posts_per_page' => 1, 'orderby' => 'ID', 'order' => 'ASC','category_name' => 'bon-vivant-premium-plywood') );
$active = 'active';
$num = 0;
while ( have_rows('carousel_slider') ) : the_row();
?>
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $num ?>" class="<?php echo $active ?>"></li>
<?php
$active = '';
$num += 1;
endwhile; ?>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
query_posts( array( 'post_type' => 'Carousel', 'posts_per_page' => 1, 'orderby' => 'ID', 'order' => 'ASC','category_name' => 'bon-vivant-premium-plywood') );
$active = 'active';
while ( have_rows('carousel_slider') ) : the_row();
?>
<div class="carousel-item <?php echo $active ?> screen08">
<div class="container">
<?php
$image = the_sub_field('image');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
</div><!-- /item -->
<?php $active = '';
endwhile;
?>
</div>
</div>
</div>
</div><!-- /row -->
am trying to fetch from the custom post type Carousel with category name. nothing display can any one help me on these
<div class="carousel_bg">
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<?php query_posts( array( 'post_type' => 'Carousel', 'posts_per_page' => 1, 'orderby' => 'ID', 'order' => 'ASC','category_name' => 'bon-vivant-premium-plywood') );
$active = 'active';
$num = 0;
while ( have_rows('carousel_slider') ) : the_row();
?>
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $num ?>" class="<?php echo $active ?>"></li>
<?php
$active = '';
$num += 1;
endwhile; ?>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
query_posts( array( 'post_type' => 'Carousel', 'posts_per_page' => 1, 'orderby' => 'ID', 'order' => 'ASC','category_name' => 'bon-vivant-premium-plywood') );
$active = 'active';
while ( have_rows('carousel_slider') ) : the_row();
?>
<div class="carousel-item <?php echo $active ?> screen08">
<div class="container">
<?php
$image = the_sub_field('image');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
</div><!-- /item -->
<?php $active = '';
endwhile;
?>
</div>
</div>
</div>
</div><!-- /row -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This results in two slides one below each other instead of a carousel - Any fixes ?