Languages: English • Italiano • posts 日本語 (Add your language)
Rewind the loop posts in order to re-use the same query in different locations on a page.
<?php rewind_posts(); ?>
This function does not accept any parameters.
This function does not return any values.
// main loop <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php the_content(); ?> <?php endwhile; endif; ?> // rewind <?php rewind_posts(); ?> // new loop <?php while (have_posts()) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?>
// main loop
<?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; ?>
<?php get_header(); ?>
<?php if (have_posts()): ?>
<header>
// initialize posts
<?php the_post();
_e('All Post by :'); echo get_the_author(); ?>
<?php if (get_the_author_meta( 'description' )): ?>
<?php the_author_meta('description'); ?>
<?php endif; ?>
</header>
// rewind posts
<?php rewind_posts(); ?>
<?php while (have_posts()): the_post();
endwhile; endif;?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
rewind_posts() is located in wp-includes/query.php.