Advertisement
alchymyth

three col loop

May 25th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <section>
  2.  
  3.     <div id="news">
  4.  
  5.         <?php $list_news = new WP_Query('cat=3&showposts=-1'); ?>
  6.         <?php $count = 0; ?>
  7.         <?php while ($list_news->have_posts()) : $list_news->the_post(); $do_not_duplicate = $post->ID; ?>
  8.         <?php $count++; ?>
  9.         <?php if ($count == 1) : ?>
  10.        
  11.         <div class="col_one">
  12.    
  13.             <article>
  14.    
  15.                 <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
  16.    
  17.                 <?php the_content(); ?>
  18.    
  19.             </article>
  20.    
  21.         </div> <!-- col_one -->
  22.  
  23.         <?php elseif ($count == 2 || $count == 3 || $count == 4) : ?>
  24.    
  25.         <?php if ($count == 2) : ?>
  26.         <div class="col_two">
  27.         <?php endif; ?>
  28.  
  29.             <article>
  30.        
  31.                 <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
  32.        
  33.                 <?php the_content(); ?>
  34.        
  35.             </article>
  36.            
  37.         <?php if ($count == 4 || ($list_news->current_post+1) == $list_news->post_count ) : ?>
  38.         </div> <!-- col_two -->
  39.         <?php endif; ?>
  40.          
  41.         <?php else : ?>
  42.  
  43.         <?php if ($count == 5) : ?>
  44.         <div class="col_three">
  45.         <?php endif; ?>
  46.  
  47.             <article>
  48.    
  49.                 <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
  50.    
  51.             </article>
  52.  
  53.         <?php if ( ($list_news->current_post+1) == $list_news->post_count ) : ?>
  54.         </div> <!-- col_three -->
  55.         <?php endif; ?>
  56.        
  57.         <?php endif; ?>
  58.         <?php endwhile; ?>
  59.  
  60.     </div> <!-- end news -->
  61.  
  62. </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement