簡體   English   中英

WordPress:逐月獲取帖子,布局問題

[英]Wordpress: Getting Month by Month posts, issue with layout

我遇到了一個問題,我每個月都會收到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,我認為我在查詢中缺少一些基本知識。

所以看來,如果我將關閉div刪除到grid_4-它現在可以工作了...

在dom中,現在所有內容都位於容器內...但是,看一下模板標記代碼,我又短了一個div ...

我不知道為什么會這樣,但這是...有一天我會弄清楚為什么,但是現在wordpress自動添加了一個額外的div。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM