/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $num_cols = 4; // set the number of columns here $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for pagination '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('« Older Entries'); previous_posts_link('Newer Entries »'); else: echo 'no posts'; endif; wp_reset_query(); ?>
URL: http://www.transformationpowertools.com/wordpress/playing-with-columns-stacking-posts-grid-style