我在wordpress网站上做了一个网格博客布局,我从一个朋友那里得到了一些代码的帮助。它每行显示3个帖子,但不会超过2行,所以当有更多帖子时,它只显示6个帖子。我知道我需要扩展我的代码来实现这一点,但我不确定如何实现。这是我目前的单曲。php文件
<?php get_header(); ?>   
    <div class="page-header">
        <div class="container">
        </div>
    </div>
<div class="page-header2">
<h1> - Remodeling 101 - </h1>
</div>
<div class="blog-bg">
  <div class="container">
    <div class="row">
    <?php
    $the_query = new WP_Query("showposts=6&orderby=date");
    $i = 0;
    while ( $the_query ->have_posts() ) {$the_query ->the_post(); $i++;
        if ($i == 1){echo "<div class=row>";}
        ?>
        <div class="col-md-4">
            <article class="post">
                <?php if ( has_post_thumbnail() ): ?>
                    <?php echo the_post_thumbnail();?>
                <?php endif;?>
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <hr>
                <div class="blog-desc">
                    <p>
                        on <?php echo the_time(\'l, F jS, Y\');?>
                        <a href="<?php comments_link(); ?>"></a>
                    </p>
                    <?php the_excerpt(); ?>
                </div>
            </article>
        </div>
        <?php
        if ($i == 3){echo "</div><div class=row>";}
        if ($i == 6){echo "</div>";}
    }
    wp_reset_postdata();
    ?>
    </div>
  </div>
</div>
<?php get_footer(); ?>