How to put bootstrap slider 4 in wordpress

Asked

Viewed 106 times

0

I’m having difficulty implementing the slider of bootstrap 4 inside wordpress, I created a custom post type called promotion where the highlighted image will stay on the slide. Follow my code. I’ve tried it many ways. I’ll be very grateful if someone can help me.

<?php get_header(); ?>
<div class="content-wrapper">
<main>
    <div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
      <div class="carousel-inner">
            <?php 
                    $arg = array(
                    'post_type'             => 'promocao',
                    'posts_per_page'        => 5,
                    'ignore_sticky_posts'   => true,
                    );

                    $loop = new WP_Query($arg);
                    if($loop->have_posts()):
                        while($loop->have_posts()):
                            $loop->the_post();
             ?>
        <div class="carousel-item active">
            <?php the_post_thumbnail(array('class'=>'d-block w-100')); ?>
        </div>
      </div>
      <a class="carousel-control-prev" href="#carouselExampleFade" 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="#carouselExampleFade" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>      
        <?php
            endwhile;
            wp_reset_postdata();
            endif;
        ?>
</main>
</div>
<?php get_footer(); ?

========================================================================

1 answer

-2

Try this

<?php $c = 0; ?>
<div class="carousel-item <?php $c++; if($c == 1 ) { echo "active"; } ?>">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.