Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Portfolio Loop

By: Zeaks on Nov 6th, 2012  |  syntax: PHP  |  size: 1.59 KB  |  views: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /**
  3.  * The loop to show posts in columns
  4.  * loop-grid.php
  5.  * Grid style page template with Nivo Slider
  6.  */
  7. ?>
  8.  
  9. <?php /* Start the Loop */ ?>
  10.  
  11. <?php $num_cols = 4; // set the number of columns here
  12.  
  13. for ( $i=1 ; $i <= $num_cols; $i++ ) :
  14.         echo '<div class="column col-' . $i . '" >';
  15.         $counter = $num_cols + 1 - $i; ?>
  16.  
  17. <?php while (have_posts()) : the_post();
  18.         if( $counter%$num_cols == 0 ) :
  19.  
  20. // begin of core posts output ?>
  21.  
  22.         <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  23.                 <header class="entry-header">
  24.                         <h1 class="entry-title">
  25.                                 <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
  26.                         </h1>
  27.                 </header><!-- .entry-header -->
  28.  
  29.                 <div class="portfolio-thumb">
  30.                         <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyetwelve' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail('portfolio-thumbnail', 'class=alignleft'); ?></a>
  31.                 </div>
  32.  
  33.                 <div class="entry-summary">
  34.                         <?php echo get_the_portfolio_excerpt(); ?>
  35.                 </div><!-- .entry-summary -->
  36.         </article><!-- #post -->
  37.  
  38.         <?php //end of posts output
  39.  
  40.         endif; $counter++;
  41.                 endwhile;
  42.                         rewind_posts();
  43.                 echo '</div>'; //closes the column div
  44.         endfor; ?>
  45.  
  46.         <?php /* Display navigation or wp-PageNavi if installed */ ?>
  47.                 <?php if (  $wp_query->max_num_pages > 1 || get_query_var('page')) : ?>
  48.                         <?php twentytwelve_content_nav( 'nav-below' ); ?>                      
  49.                 <?php endif;
  50.                 wp_reset_query(); ?>