Php 当没有';t职位数目相等

Php 当没有';t职位数目相等,php,wordpress,twitter-bootstrap-3,Php,Wordpress,Twitter Bootstrap 3,如果我没有8根柱子,旋转木马就像这样 这是Wordpress循环 <div class="section-title"> <h1>Most Recent Post</h1> </div> <div id="recent-post-carousel" class="carou

如果我没有8根柱子,旋转木马就像这样

这是Wordpress循环

                <div class="section-title">
                    <h1>Most Recent Post</h1>
                </div>                  
                <div id="recent-post-carousel" class="carousel slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                        <li data-target="#recent-post-carousel" data-slide-to="0" class="active"></li>
                        <li data-target="#recent-post-carousel" data-slide-to="1"></li>

                    </ol>
                    <div class="carousel-inner">










                   <?php
                    // Get posts (tweak args as needed)
                    $i=0;
                    $args = array(
                        'post_type'        => 'post',
                        'posts_per_page'   => -1,
                        'orderby' => "date",
                        'order' => "desc"
                    );
                    $posts = get_posts( $args );
                ?>

                <?php foreach (array_chunk($posts, 4, true) as $posts) :  ?>
                <div class="item <?php if ($i==0){echo 'active';}?>">            
                    <div class="row">

                        <?php foreach( $posts as $post ) : setup_postdata($post); ?>

                           <div class="col-sm-6">
                                    <div class="single-post">
                                        <div class="pull-left post-image">
                                            <a href="#">
                                                <?php the_post_thumbnail( 'full' );  ?>
                                                <i class="fa fa-angle-right"></i>
                                            </a>
                                        </div>
                                        <div class="pull-right post-details">
                                            <p class="post-date">03 Dec 2014</p>
                                            <p><?php echo $i?></p>

                                            <a href="#"><h5><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
                            </h5></a>
                                            <span>John doe</span>
                                            <p><?php echo substr(get_the_excerpt(), 0,99).' [...]'; ?></p>
                                        </div>
                                    </div>
                                </div>
                        <?php $i++ ?>

                        <?php endforeach; ?>

                    </div>

                        </div>

                <?php endforeach; ?>










                    </div>
                </div>
            </div>

最近的职位

  • 不确定它是否与wordpress有关,我在一个静态页面上尝试了它,效果很好。解决这个问题的一个方法是从col-sm-6中删除左边或右边距,但我认为这不是一个好方法。

    我为您创建了一个提琴。在小提琴中,上面一个是你的情况,下面一个是最小高度的情况(已解决)


    如果仍然无法修复,请尝试将类“cleafix”与“single post”一起添加。

    我已经为您创建了一个提琴。在小提琴中,上面一个是你的情况,下面一个是最小高度的情况(已解决)


    如果仍然无法修复,请尝试将类“cleafix”与“single post”一起添加。

    您确定这与帖子数量有关吗?这看起来像是一个CSS浮动问题…是的,当我有8篇文章时效果很好,但不是6篇或7篇。这不是因为文章的数量。这是由于不同高度的职位。尝试将最小高度添加到帖子。最小高度无效。它在静态页面上工作得很好,但是一旦进入引导循环,当没有8篇文章时,它就会出错。你确定这与文章的数量有关吗?这看起来像是一个CSS浮动问题…是的,当我有8篇文章时效果很好,但不是6篇或7篇。这不是因为文章的数量。这是由于不同高度的职位。尝试将最小高度添加到帖子。最小高度无效。它在静态页面上工作得很好,但是一旦在引导循环中,当没有8个poststhank you我将最小高度添加到错误的元素时,它就会出错。花了两个小时试图弄明白这一点谢谢,我把最小高度添加到了错误的元素中。花了两个小时想弄明白
    **https://jsfiddle.net/Anuj_Kumar/L5uduxLr/1/embedded/result/**