WordPress.org

Support

Support » How-To and Troubleshooting » Can’t keep those loops separate

Can’t keep those loops separate

  • For some reason this is getting mixed up with the main loop and looping through ALL of the posts and not just one…

    Any ideas?

    $temp_query = $wp_query;
    	$randposts = new WP_Query('posts_per_page=1&orderby=rand');
    	if ( $randposts->have_posts() ) : while ( $randposts->have_posts() ) : $randposts->the_post(); 
    
    <do stuff>
    
    	endwhile; endif;
    	$wp_query = $temp_query;
  • The topic ‘Can’t keep those loops separate’ is closed to new replies.