WordPress.org

Ready to get started?Download WordPress

Forums

Can't keep those loops separate (1 post)

  1. rpophessagr
    Member
    Posted 4 years ago #

    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;

Topic Closed

This topic has been closed to new replies.

About this Topic