rewind_posts()

Rewind the loop posts.


Description Description


Source Source

File: wp-includes/query.php

function rewind_posts() {
	global $wp_query;
	$wp_query->rewind_posts();
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by leogermani

    Example with custom query migrated from Codex

    <?php 
    $args = array('posts_per_page' = -1);
    $my_posts = new WP_Query($args);
    if ($my_posts->have_posts()) : while ($my_posts->have_posts()) : $my_posts->the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>
    
    // rewind
    <?php $my_posts->rewind_posts(); ?>
    
    // new loop
    <?php while ($my_posts->have_posts()) : $my_posts->the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>

You must log in before being able to contribute a note or feedback.