Advertisement
Kortschot

$count loop

May 25th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 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.         <div class="col_two">
  26.  
  27.             <article>
  28.        
  29.                 <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
  30.        
  31.                 <?php the_content(); ?>
  32.        
  33.             </article>
  34.  
  35.         </div> <!-- col_two -->
  36.          
  37.         <?php else : ?>
  38.  
  39.         <div class="col_three">
  40.  
  41.             <article>
  42.    
  43.                 <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
  44.    
  45.             </article>
  46.  
  47.         </div> <!-- col_three -->
  48.        
  49.         <?php endif; ?>
  50.         <?php endwhile; ?>
  51.  
  52.     </div> <!-- end news -->
  53.  
  54. </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement