﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
11698	have_posts should not auto rewind	mwillberg		"When the loop has been exhausted the have_posts will auto rewind itself. ALL documentation and examples are not valid as they claim that have_posts() will return false when there are no more posts in query.

Example, this will incorrectly go thru the loop twice:

{{{
while (have_posts()) {the_post();the_title();}
while (have_posts()) {the_post();the_title();}
}}}


the later loop should not do anything as the query has already been walked thru.


Suggested FIX, to remove the rewind_posts();

{{{
query.php / function have_posts() {
...
do_action_ref_array('loop_end', array(&$this));
// Do some cleaning up after the loop
// $this->rewind_posts();
...
}
}}}

Life after the fix:

If someone really wants to revert to old behaviour, it is already possible to do easily. So AFTER the issue has been fixed (ie. rewinding has been removed):

{{{
while (have_posts()) {the_post();}

if (!have_posts()) {rewind_posts();}
while (have_posts()) {the_post();}
}}}
"	defect (bug)	closed	normal		General		minor	wontfix	dev-feedback 2nd-opinion	purewhite
