Return to Snippet

Revision: 48306
at June 28, 2011 22:31 by akmuraro


Initial Code
<?php $num_cols = 4; // set the number of columns here
$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, // add any other query parameter to this array
'paged' => $paged
); query_posts($args);
if (have_posts()) :
for ( $i=1 ; $i <= $num_cols; $i++ ) :
echo '<div id="col-'.$i.'" class="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('&laquo; Older Entries');
previous_posts_link('Newer Entries &raquo;');
else:
echo 'no posts';
endif; wp_reset_query(); ?>

Initial URL
http://www.transformationpowertools.com/wordpress/playing-with-columns-stacking-posts-grid-style

Initial Description

                                

Initial Title
Wordpress Post grid

Initial Tags
wordpress

Initial Language
PHP