$query = new WP_Query( array( 'posts_per_page' => 5 ) ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); the_title(); the_excerpt(); } } // Rewind the posts $query->rewind_posts(); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); the_title(); the_excerpt(); } }
$args = array( 'post_type' => 'product', 'meta_query' => array( array( 'key' => 'price', 'value' => '50', 'compare' => '>', 'type' => 'NUMERIC' ) ) ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // Display product info } } // Rewind the posts $query->rewind_posts();This code creates a query that returns products with a price greater than 50, loops through them once and displays their information, then rewinds the posts. The package library for WP_Query rewind_posts is WordPress.