Posted By

akmuraro on 06/28/11


Tagged

wordpress grid


Versions (?)

Wordpress Post grid


 / Published in: PHP
 

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

  1. <?php $num_cols = 4; // set the number of columns here
  2. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for pagination
  3. $args = array(
  4. 'posts_per_page' => 16, // optional to overwrite the dashboard setting
  5. 'cat' => 0, // add any other query parameter to this array
  6. 'paged' => $paged
  7. ); query_posts($args);
  8. if (have_posts()) :
  9. for ( $i=1 ; $i <= $num_cols; $i++ ) :
  10. echo '<div id="col-'.$i.'" class="col">';
  11. $counter = $num_cols + 1 - $i;
  12. while (have_posts()) : the_post();
  13. if( $counter%$num_cols == 0 ) : ?>
  14. <!-- core post area;
  15. title, content, thumbnails, postmeta, etc -->
  16. <?php endif; $counter++;
  17. endwhile;
  18. rewind_posts();
  19. echo '</div>'; //closes the column div
  20. endfor;
  21. next_posts_link('&laquo; Older Entries');
  22. previous_posts_link('Newer Entries &raquo;');
  23. else:
  24. echo 'no posts';
  25. endif; wp_reset_query(); ?>

Report this snippet  

You need to login to post a comment.