Print All post 2 Columns in wordpress
-
I Used Bellow code for print month and all post title. I use this code and I get the out put I need yet I need the month on the left hand side. When the monthly post number is even the month stay to left, however if the number is an odd number the month goes to a wrong place.
<?php
$blogtime = date(‘Y’);
$prev_limit_year = $blogtime – 1;
$prev_month = ”;
$prev_year = ”;$args = array(‘post_type’ => ‘post’,’post_status’ => ‘publish’,’posts_per_page’=>-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) {?>
<div class=”col-sm-12″>
<h2><?php echo get_the_time(‘F, Y’)?></h2>
</div>
<?php } ?><div class=”col-sm-6″>
<h3>“><?php the_title(); ?></h3>
</div><?php
$prev_month = get_the_time(‘F’);
$prev_year = get_the_time(‘Y’);
} ?>
- The topic ‘Print All post 2 Columns in wordpress’ is closed to new replies.