Wordpress: Getting Month by Month posts, issue with layout

BaphImalp

New Member
I've got an issue where I'm getting the wordpress posts month by month, but I'm missing something obvious where by it screws with my layout a bit. I'm using the 996 grid system for my layout. The NEED: I'm getting all posts in March 2013 and wanting to lay them out each inside a so 3 posts are stacked like screenshot A.
lqx7b.png
My code is below: \[code\]<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="http://stackoverflow.com/questions/15717880/<?php the_permalink(); ?>"><?php the_post_thumbnail('standard-thumb'); ?></a> <h3><a href="http://stackoverflow.com/questions/15717880/<?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 -->\[/code\]THE PROBLEM: With the above code, every single instance of grid_4 sits outside the container EXCEPT the first one. See Screenshot B
WbisF.png
How can I make sure all grid_4 divs are included inside the container? I've tried moving the div which doesent work, I think I'm missing something fundamental from the query.
 
Back
Top