Advertisement
S3nd41

Dual Loop Final

Jan 17th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1.     <?php
  2.     // First query
  3.     $my_query = new WP_Query;
  4.     $my_query->query( array( 'numberposts' => '6' ) );
  5.  
  6.     // If first query have posts
  7.     if( $my_query->have_posts() ) :
  8.  
  9.         $count = 0;
  10.  
  11.         // While first query have posts
  12.         while ($my_query->have_posts()) : $my_query->the_post();
  13.  
  14.             // Setup vars
  15.             $count++;
  16.             $incr_number = get_post_meta( $post->ID,'incr_number',true);
  17.         ?>
  18.  
  19.         <!-- start post -->
  20.  
  21. FIRST GROUP OF POSTS CODE
  22.  
  23.          <!-- end post -->
  24.  
  25.             <?php
  26.  
  27.             // If count is equal to 6
  28.             if($count % 6 ==0  && $count !=0) :
  29.  
  30.                                 // Second query
  31.                                 $my_second_query = new WP_Query;
  32.                                 $my_second_query->query('offset='.$myOffset.'&showposts=6');
  33.  
  34.                                 // If second query have posts
  35.                                 if( $my_second_query->have_posts() ) :
  36.                                    
  37.                                         // While second query have posts
  38.                                         while( $my_second_query->have_posts() ) : $my_second_query->the_post(); $myOffset++; ?>
  39.  
  40.         <!-- start post -->
  41.  
  42. SECOND GROUP OF POSTS CODE
  43.  
  44.          <!-- end post -->
  45.  
  46.         <?php endwhile; ?>
  47.  
  48.                 <?php
  49.                 // End if second query have posts
  50.                 endif; ?>
  51.  
  52.                 <?php
  53.                 // End if second query have posts
  54.                 endif; ?>
  55.  
  56.         <?php
  57.         // End first while have posts
  58.         endwhile; ?>
  59.  
  60.     <?php
  61.     // End if first query have posts
  62.     endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement