You could always try to create 2 arrays of titles, say $left and $right, $odd and $even, or $tom and $jerry, and fill them with the titles during your loop, and print them after the loop has ended like so:
Create array
$left = $right = array();
Then unleash your loop [edited the below to reflect the comments]
<?php // The loop
if ( $query->have_posts() ) : $row_start = 1;
while ( $query->have_posts() ) : $query->the_post();
if ( in_array( get_the_ID(), $duplicates ) ) continue;
if( $row_start % 2 != 0) {
// odd: add result to $left
// $left[] = get_the_title();
$left[] = $post->id;
} else {
// even: add it to $right
//$right[] = get_the_title();
$right[] = $post->id;
}
++$row_start; endwhile; wp_reset_postdata();
// now loop has ended and we have 2 full arrays
// that we can print each in it's div
print "<div class=\"left\">";
foreach($left as $postID) {
$postData = get_post( $postID );
print $postData->post_title;
print $postData->post_content;
// etc... you can also get thumbnails using the post ID:
print get_the_post_thumbnail($postID, 'thumbnail');
}
print "</div>";
// next column
print "<div class=\"right\">";
foreach($right as $postID) {
// ... just like the above...
}
print "</div>";
endif;
?>
I’ve not yet tested this but it should work (or some close variation of it). I personally would output the list of posts in unordered lists (<ul class="right or left">
) and put each title in an <li>
.
Good luck 🙂