• tonety_bcn

    (@tonety_bcn)


    Hello!
    Need to print post this way:
    1 2
    3 4
    5 6
    Show more..
    And I’m getting allways:
    1 1
    2 2
    3 3
    4 4
    5 5
    Can somebody help me with this issue?
    Thanks in advance for your help!!

    Here is the code:

    <div class="row">
    
    				<div class="col-md-6">
    				<ul class="media">
    				<?php while (have_posts()) : the_post(); ?><?php // loop through posts discarding evens ?>
    				<li class="media">
    				<?php the_post_thumbnail('thumbnail'); ?>
    				<h3 class="grey"><a>" rel="bookmark"><?php the_title(); ?></a></h3>
    
    				<?php endwhile; ?>
    
    				</div>
    				<div class="col-md-6">
    				<ul class="media">
    				<?php while (have_posts()) : the_post(); ?><?php // loop through posts discarding odds ?>
    				<li class="media">
    				<?php the_post_thumbnail('thumbnail'); ?>
    				<h3 class="grey"><a>" rel="bookmark"><?php the_title(); ?></a></h3>
    
    				<?php endwhile; ?>
    
    				</div>
    
    	</div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    <div class="row">
    
    				<div class="col-md-6">
    				<ul class="media">
    				<?php while (have_posts()) : the_post(); ?><?php // loop through posts discarding evens ?>
    				<?php if( $wp_query->current_post%2 == 0 ) : //only output for ODD posts// ?>
    
    				<li class="media">
    				<?php the_post_thumbnail('thumbnail'); ?>
    				<h3 class="grey"><a>" rel="bookmark"><?php the_title(); ?></a></h3>
    				</li>
    
    				<?php endif; //end of output for ODD posts// ?>
    				<?php endwhile; ?>
    
    				</ul></div>
    				<div class="col-md-6">
    				<ul class="media">
    				<?php rewind_posts(); //rewind the post to start anew//
    				while (have_posts()) : the_post(); ?><?php // loop through posts discarding odds ?>
    				<?php if( $wp_query->current_post%2 == 1 ): //only output for EVEN posts// ?>
    
    				<li class="media">
    				<?php the_post_thumbnail('thumbnail'); ?>
    				<h3 class="grey"><a>" rel="bookmark"><?php the_title(); ?></a></h3>
    				</li>
    
    				<?php endif; //end of output for EVEN posts// ?>
    				<?php endwhile; ?>
    
    				</ul></div>
    
    	</div>

    CAVEAT:
    be aware that some of the code was broken in your posting; you will need to repair the link html etc….

    for future posting of code, please read http://codex.wordpress.org/Forum_Welcome#Posting_Code

    Thread Starter tonety_bcn

    (@tonety_bcn)

    Wow! that was quick 😉 and accurate! Thank you for your help Alchymyth, I fixed the broken link and everything works perfectly. I appreciate.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘evens & odds by columns’ is closed to new replies.