Advertisement
alchymyth

two columns of posts

Mar 27th, 2011
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. ADAPTED from my post: http://www.transformationpowertools.com/wordpress/playing-with-columns-stacking-posts-grid-style
  2.  
  3.  
  4. <?php query_posts( $query_string . '&posts_per_page=-7' ); ?>
  5.  
  6. <?php $num_cols = 2; // set the number of columns here
  7.  
  8. for ( $i=1 ; $i <= $num_cols; $i++ ) : ?>
  9.  
  10. <div id="post-column-<?php echo $i; ?>" class="post-column">
  11.  
  12. <?php $counter = $num_cols + 1 - $i;
  13.  
  14. while (have_posts()) : the_post();
  15. if( $counter%$num_cols == 0 ) : ?>
  16.  
  17. <div class="news_item_a column<?php echo $i; ?>" id="post-<?php the_ID(); ?>">
  18.             <h2 class="contentheading"> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h2>
  19.             <div class="newsitem_tools">
  20.               <div class="newsitem_info">
  21.                 <span class="createdate"> <?php the_time('j F Y, h:m') ?> </span> <span class="createby"> <?php the_author() ?> </span>
  22.               </div>
  23.               <!-- end of info-->
  24.             </div>
  25.             <!-- end of tools-->
  26.             <div class="newsitem_text">
  27.               <div class="news_item_article">
  28.               <img class="thumb" src="<?php echo catch_that_image() ?>" border="0" alt="<?php the_title(); ?>" />
  29.                 <?php the_excerpt(); ?>
  30.                 <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); // for multi page posts ?>
  31.                 <p><a rel="nofollow" class="readon" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><span style="display: none;"><?php the_title(); ?></span></a></p>
  32.  
  33.               </div>
  34.             </div>
  35.             <span class="article_separator">&nbsp;</span>
  36.          </div>
  37.  
  38. <?php endif; $counter++;
  39. endwhile;
  40. rewind_posts(); ?>
  41.  
  42. </div> <!--closes the .post-column div-->
  43.  
  44. <?php endfor; ?>
  45.  
  46.  
  47.  
  48. CSS for the above
  49.  
  50. .post-column { float: left; width: 49%; margin-left: 1%; }
  51. #post-column-1 { margin-left: 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement