Lego2012
12/13/2016 - 11:42 AM

Loop the loop

Loop the loop

<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.

<!-- 
Or… add a loop within the loop, but loop the loop sounds much cooler. 
-->

if (have_posts()) :
    while (have_posts()) : the_post(); // the post loop
        $temp_query = $wp_query;  // store it
  $args = array(
  'paged' => $paged, // paginates
  'post_type'=>'post',
  'posts_per_page' => 3,
  'order' => 'DESC'
  );
  $wp_query = new WP_Query($args);
  while ($wp_query->have_posts()) : $wp_query->the_post();
            // -- your new loop -- //
        endwhile;
        if (isset($wp_query)) {$wp_query = $temp_query;} // restore loop
    endwhile;
endif;