Необходимость rewind_posts()
-
Здравствуйте!
В док-тации приведен код:// 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; ?>
Не могу понять, зачем здесь rewind_posts()? Ведь метод have_posts() автоматически её запускает по окончании цикла:
public function have_posts() { if ( $this->current_post + 1 < $this->post_count ) { return true; } elseif ( $this ->current_post + 1 == $this->post_count && $this->post_count > 0 ) { do_action_ref_array( 'loop_end', array( &$this ) ); $this->rewind_posts(); //перемотка цикла в начало } $this->in_the_loop = false; return false; }
Просмотр 4 ответов — с 1 по 4 (всего 4)
Просмотр 4 ответов — с 1 по 4 (всего 4)
- Тема «Необходимость rewind_posts()» закрыта для новых ответов.