dragunoff

wpquestions.com, ID = 2961

Sep 11th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php // First Image Loop
  2.  
  3. $args=array(
  4.     'post_type' => 'animals',
  5.     'orderby' => 'rand',
  6.     'posts_per_page' => 7
  7. );
  8.  
  9. $i = 0; // set counter at 0
  10. $query = new WP_Query($args);
  11.  
  12. while($query->have_posts()) : $query->the_post();
  13.  
  14.     // different code for each image based on the counter
  15.     switch ($i) {
  16.         case 0:
  17.             echo "first image - {$post->ID}";
  18.             break;
  19.         case 1:
  20.             echo "second image - {$post->ID}";
  21.             break;
  22.         case 2:
  23.             echo "third image - {$post->ID}";
  24.             break;
  25.     }
  26.    
  27.     $i++ // increment counter
  28.    
  29. endwhile;
  30.    
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment