if you know how many columns you can get/or want, you can run a counter and add ‘clear:left;’ to the first post on a new row; this prevents the sticking of the posts and keeps a bit more order even is the posts have different lengths.
<?php if(have_posts()) :
$counter = 0; $num_cols = 4; // set number of columns
while(have_posts()) : the_post(); ?>
<div class="post<?php if($counter%$num_cols == 0) echo ' clear'; ?>">
<!-- all the html and other stuff to show post -->
</div>
<?php &counter++;
endwhile;
else : /*no post*/ endif; ?>
style.css:
.post { width:150px; /*or any other fixed width*/
float:left;
margin-right: 10px; /*to separate the columns horizontally*/
}
.clear { clear:left; }
___________
a different approach to ‘grid style’ – to get a similar design as in the https://www.creativedepart.com/ link:
(bare minimum code, without explanation)
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for pagination
$args = array(
'posts_per_page' => 16, // optional to overwrite the dashboard setting
'cat' => 0,
'paged' => $paged
); query_posts($args);
if (have_posts()) :
$num_cols = 4; // set the number of columns here
for ( $i=1 ; $i <= $num_cols; $i++ ) :
echo '<div id="col">';
$counter = $num_cols + 1 - $i;
while (have_posts()) : the_post();
if( $counter%$num_cols == 0 ) : ?>
<!-- core post area;
title, content, thumbnails, postmeta, etc -->
<?php endif; $counter++;
endwhile;
rewind_posts();
echo '</div>'; //closes the column div
endfor;
next_posts_link('« Older Entries');
previous_posts_link('Newer Entries »');
else:
echo 'no posts';
endif; wp_reset_query(); ?>
minimum css:
.col { width:150px; float:left; margin-right:5px; }