-
-
Save vicso-name/34b06ec054ed5dece4102603855e11f8 to your computer and use it in GitHub Desktop.
Testimonial carousel | Wordpress | ACF | Bootstrap
This file contains 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('testimonials') ): | |
echo '<div id="testimonials" class="carousel slide" data-ride="carousel" data-pause="false">'; | |
echo '<div class="carousel-inner">'; | |
$count = 1; | |
while( have_rows('testimonials') ): the_row(); | |
$testimonial = get_sub_field('testimonial_text'); | |
$author = get_sub_field('testimonial_author'); | |
echo '<div class="carousel-item text-center py-5'; | |
if ( $count == 1 ) { | |
echo ' active'; // Add the active class to the first row | |
} | |
echo '">' . PHP_EOL; | |
echo '<blockquote class="w-50 mx-auto my-0 py-5">'; | |
echo '<p class="h1 mb-5">“' . $testimonial . '”</p>'; | |
if ( $author ) { | |
$role = get_sub_field('testimonial_role'); | |
echo '<hr>'; | |
echo '<footer><cite>' . $author; | |
if ( $role ) { | |
echo '<br>' . $role; | |
} | |
echo '</cite></footer>'; | |
} | |
echo '</blockquote>'; | |
echo '</div>'; // Close .carousel-item | |
$count++; // So we can establish the first post and attach the mandatory active class | |
endwhile; | |
echo '</div>'; // Close .carousel-inner | |
echo '</div>'; // Close .carousel | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment