最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

loop - how to add 4 post in one carousel slide

programmeradmin1浏览0评论

I want to display 8 posts in twoeach carousel slides, that mean 4 post in each slide. i'm using a loop to display post but the problem is, it is showing one post in one slide and hence displaying 8 slides.

<div class="carousel-inner">
    <?php  
        query_posts("posts_per_page=8&post_type=post&category_name=Hector");
            if ( have_posts() ) :
                $i = 1;
                while ( have_posts() ) : the_post();
    ?>
                    <div class="carousel-item <?php if ( $i == 1 ){ echo 'active'; } ?>">
                        <div class="col-md-3">
                            <a href="/">
                                <img src="<?php the_post_thumbnail_url(); ?>"alt="<?php  the_title() . ' feature image'; ?>" style="max-width:100%;">
                                            <h3><?php  the_title(); ?></h3>
                            </a>
                        </div>  
    <?php
                        if($i % 4 == 0):
    ?>           
                    </div>
    <?php
                    endif;
                    $i++;
                endwhile;
            endif;
    ?>
</div>
发布评论

评论列表(0)

  1. 暂无评论