[wp-hackers] Resetting after multiple loops
Nigel Dunn
nigel at redefine.co.uk
Sat Oct 25 16:02:41 GMT 2008
Hi Otto
Otto wrote:
> Harumph. Maybe I just like Object Oriented code more.
>
> $myquery = new WP_Query('whatever');
> while ($myquery->have_posts()) : $myquery->the_post();
> the_title();
> the_content();
> endwhile;
I must admit that I'm with you on this, in fact I'd like to be able to
do $myquery->the_title(); etc.
I had started with previous projects using get_posts but wasn't
comfortable with having to use global $post; to get it to work - and
then seeing the list of globals in function load_template() I was
concerned about making sure there weren't other side-effects.
So I switched over to WP_Query after looking at the codex on loops as I
had hoped that wp_reset_query() would have put everything back to its
original state. But it doesn't seem to do that for me - have you had a
similar issue or is there something else I should be doing?
Cheers
Nigel
--
Nigel Dunn
Redefine
0845 838 2720
http://www.redefine.co.uk
More information about the wp-hackers
mailing list