How to prevent post to repeat on my loop?

i’m new at wordpress development and i created custom post type to include in a Bootstrap carousel. It works but is repeating my first slide. How can i prevent this?

Here’s my code:

<section role="banners-wrapper" class="row">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner" role="listbox">
        <?php $the_query = new WP_Query(array(
            'post_type' => 'Banners', 
            'posts_per_page' => 1 
        ));
        while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <div class="carousel-item active">
            <img class="img-fluid" src="<?php the_field('banner-image'); ?>">
        </div>
        <?php endwhile; wp_reset_postdata(); ?>
        <?php $the_query = new WP_Query(array(
            'post_type' => 'Banners', 
            'posts_per_page' => -1, 
            'offset' => 1 
            ));
        while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <div class="carousel-item">
            <img class="img-fluid" src="<?php the_field('banner-image'); ?>">
        </div>
        <?php endwhile; ?>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
</section>

Any thoughts?
Best regards

Read more here: How to prevent post to repeat on my loop?

Leave a Reply

Your email address will not be published. Required fields are marked *