[wp-hackers] Loops and Cloning
Mark Jaquith
mark.wordpress at txfx.net
Sat Nov 1 02:27:51 GMT 2008
On Oct 31, 2008, at 5:27 PM, Jess Planck wrote:
> $temp_wp_query = wp_clone( $wp_query );
> $temp_post = wp_clone( $post );
It's better to just instantiate your own WP_Query object.
$custom_loop = new WP_Query( array(
'category_name' => $page_category_name[0],
'showposts' => get_option('posts_per_page')
));
while ( $custom_loop->have_posts() ) $custom_loop->the_post();
// normal loop functions here
endwhile;
That way, the normal $wp_query isn't touched at all, and things that
depend on it don't break.
--
Mark Jaquith • http://markjaquith.com/
More information about the wp-hackers
mailing list