0

我遇到了一个问题,我每个月都会收到 wordpress 帖子,但我错过了一些明显的东西,因为它与我的布局有点冲突。我正在使用 996 网格系统进行布局。

需求:

我在 2013 年 3 月收到所有帖子,并希望将它们分别放在一个里面,所以 3 个帖子像屏幕截图 A 一样堆叠。在此处输入图像描述

我的代码如下:

<div class="container clearfix" style="background:yellow;">
    <div class="grid_12" style="background:blue;">
        <?php
                $blogtime = date('Y');
                $prev_limit_year = $blogtime - 1;
                $prev_month = '';
                $prev_year = '';
                $args = array(
                    'posts_per_page' => 20,
                    'ignore_sticky_posts' => 1
                );
                $postsbymonth = new WP_Query($args);

                while($postsbymonth->have_posts()) {
                    $postsbymonth->the_post();
                    if(get_the_time('F') != $prev_month || get_the_time('Y') != $prev_year && get_the_time('Y') == $prev_limit_year) {

                        echo "<h2>".get_the_time('F, Y')."</h2>\n\n";

                        }
            ?>
    </div>

<div class="grid_4" style="background:red;">
    <article id="post-<?php the_ID(); ?>" role="article" itemscope itemtype="http://schema.org/BlogPosting">
        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('standard-thumb'); ?></a>
        <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    </article>
</div>

<?php
$prev_month = get_the_time('F');
$prev_year = get_the_time('Y');
}
    ?>
</div> <!-- END OF CONTAINER -->

问题:

使用上面的代码,grid_4 的每个实例都位于容器之外,第一个实例除外。见截图 B在此处输入图像描述

如何确保所有 grid_4 div 都包含在容器中?

我试过移动不起作用的 div,我想我在查询中遗漏了一些基本的东西。

4

1 回答 1

0

因此,如果我将关闭的 div 删除到 grid_4 似乎 - 它现在可以工作了......

在 dom 中,它现在都位于容器内......但是看看模板标记代码,我是一个 div 短......

我不知道为什么会这样,但它是......有一天我会弄清楚为什么但现在 wordpress 会自动添加一个额外的 div。

于 2013-03-30T13:34:46.613 回答