In wordpress, I am getting the data from database. The problem is that I want to show the data in different order like this:
--------------------------
data-1 | data-2
--------------------------
data-3 | data-4 | data-5
_________________________
data-6 | data-7 | data-8
--------------------------
data-9 | data-10
--------------------------
For now I am getting the data like this:
$args = array( 'post_type' => 'press', 'posts_per_page' => '-1');
$loop = new WP_Query( $args );
$i = 0;
while ( $loop->have_posts() ) : $loop->the_post();
$count = $loop->post_count;
foreach( $loop as $test ) {
echo $test->post_title;
if( $i % 2 == 0 ) {
?>
<div class="two-column-rows pressrelease-columns">
<div class="first"><?php echo $test->post_title; ?></div>
<div class=""><?php echo $test->post_title; ?></div>
</div>
<?php } ?>
<?php if( $i % 2 == 1 ) { ?>
<div class="three-column-rows pressrelease-columns">
<div class="first"><?php echo $test->post_title; ?></div>
<div class=""><?php echo $test->post_title; ?></div>
<div class=""><?php echo $test->post_title; ?></div>
</div>
<?php
}
$i++;
}
endwhile; ?>
But its not working as per the reference. So can someone tell me how to resolve this?