How to reset the post query and use Multi-Pass Loop in WordPress

A rewind_posts() function is used to reset the post query and loop counter,allowing us to do another Loop using same content as first Loop.Place this function call directly after finishing first loop.

Example:-

Here is an example that processes the main Loop content twice:

<?php while(have_posts()) :the_post(); ?>
                <!------content--->
            <?php endwhile; ?>
            <?php  rewind_posts();?>
            <?php while (have_posts()) : the_post(); ?>
            <!---content---->
            <?php endwhile; ?>
            


Total Page Visits: 3702 - Today Page Visits: 2

Leave a Reply