Advertisement
alchymyth

stacked posts grid

Aug 4th, 2011
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php $num_cols = 3; // set the number of columns here
  2.  
  3. if (have_posts()) :
  4. for ( $i=1 ; $i <= $num_cols; $i++ ) :
  5. echo '<div id="col-'.$i.'" class="col">';
  6. $counter = $num_cols + 1 - $i;
  7. while (have_posts()) : the_post();
  8. if( $counter%$num_cols == 0 ) : ?>
  9.  
  10. <div class="postarray">
  11. <a class="posttitle" title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
  12. <p class="meta"> <?php the_time('jS F Y') ?>//<?php the_category(', ') ?>//<?php the_author(); ?></p>
  13. <?php the_post_thumbnail(array(300,9999), array ('class' => 'alignleft')); ?>
  14. <p class="thumbtext"><?php the_excerpt(); ?> </p>
  15. <div class="clear"></div>
  16. </div>
  17.  
  18. <?php endif; $counter++;
  19. endwhile;
  20. rewind_posts();
  21. echo '</div>'; //closes the column div
  22. endfor;
  23.  
  24. endif; ?>
  25. <div class="clear"></div>
  26.  
  27.  
  28. STYLES FOR THIS:
  29.  
  30. .postarray {width: 300px;height: auto;padding: 5px;border-bottom: solid 1px black;margin: 10px 0;float: left;display: block; }
  31.  
  32. .col { width:310px; float:left; margin-left:20px; } /*adjust values*/
  33. #col-1.col { margin-left: 0; } /*optional*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement