Posts in two columns. Newest – left – right
-
I am trying to get my posts to fall into two columns by date with the latest post at the top let column and then the next newest post at the top in right column and so on.
Left Column —- Right Column
9/9/19———–9/8/19
9/7/19———–9/6/19…and so on. I tried this and it puts them into two columns but out of oreder
<div class="container"> <div class="row"> <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?> <div class="col-md-6"> <article> <h1><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h1> <p>Posted on: <span class="meta"><?php the_time('F jS, Y'); ?></span></p> <?php the_excerpt(); ?> </article> </div> <?php endif; endwhile; else: ?> <div>Alternate content</div> <?php endif; ?> <?php $i = 0; rewind_posts(); ?> <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query->next_post(); else : the_post(); ?> <div class="col-md-6"> <article> <h1><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h1> <p>Posted on: <span class="meta"><?php the_time('F jS, Y'); ?></span></p> <?php the_excerpt(); ?> </article> </div> <?php endif; endwhile; else: ?> <div>Alternate content</div> <?php endif; ?> </div><!-- /row --> </div><!-- /container -->
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Posts in two columns. Newest – left – right’ is closed to new replies.