Title: query_posts
Last modified: August 19, 2016

---

# query_posts

 *  [tom5436](https://wordpress.org/support/users/tom5436/)
 * (@tom5436)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/query_posts-1/)
 * on query_posts is there a way to stop them if you have two loops on one page.
   My featured story loop is messing with my recent post loop

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/query_posts-1/#post-817196)
 * Give some more detail to explain the problem you’re running into. If I understand
   your question, the answer is no — `query_posts` doesn’t offer a way to only run
   one of the loops on a page. But I think you can set up some if…else statements
   on the page to only run one of them at a time if you need to. Still, more information
   about exactly what you’re trying to achieve would help answer your question.
 *  Thread Starter [tom5436](https://wordpress.org/support/users/tom5436/)
 * (@tom5436)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/query_posts-1/#post-817309)
 * I have a featured story which I have a query post on it to show the highest rated
   post. And I also have recent posts at the bottom of the home page which I use
   a query post to order by date. My featured story’s query is messing with my recent
   post and ordering it by highest rated
 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/query_posts-1/#post-817319)
 * Do you end one `query_posts` loop before you begin the other one? I can’t see
   them interfering with each other otherwise. Including a link to the way the page
   renders with both loops in action will help (think about putting your code in
   a pastebin somewhere because that might help, too).
 *  Thread Starter [tom5436](https://wordpress.org/support/users/tom5436/)
 * (@tom5436)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/query_posts-1/#post-817346)
 * ya I end the loops before starting the next one. Here are the loops
 *     ```
       <?php query_posts('r_sortby=highest_rated');?>
       <?php $recent = new WP_Query("showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
       					<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
       <img src="<?php echo get_post_meta($post->ID, "thumbnail", true);?>" width="70">
       					<?php the_excerpt();?>
       <a href="<?php the_permalink()?>">Read More</a><div style="clear:both;"></div>
       					<?php endwhile; ?>
       ```
   
 *     ```
       <?php query_posts('r_sortby=highest_rated');?>
                                     <?php $recent = new WP_Query("cat=13&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
       					<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
       <object width="300" height="246"><param name="movie" value="http://www.youtube.com/v/xLf_kvfguzE&hl=en&fs=1&rel=0&border=1"></param><param name="allowFullScreen" value="true"></param><embed src="<?php echo get_post_meta($post->ID, "Url", true);?>" type="application/x-shockwave-flash" allowfullscreen="true" width="300" height="246"></embed></object>
       <?php the_excerpt();?>
       <a href="<?php the_permalink()?>">Read More</a><div style="clear:both;"></div>
       					<?php endwhile; ?>
       ```
   
 *     ```
       query_posts('r_sortby=highest_rated');?>
                                     <?php $recent = new WP_Query("cat=34&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
       					<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo get_post_meta($post->ID, "Hero_Name", true);?></a></b>
       <img src="<?php echo get_post_meta($post->ID, "thumbnail", true);?>" width="70">
       					<?php the_excerpt();?>
       <a href="<?php the_permalink()?>">Read More</a><div style="clear:both;"></div>
       					<?php endwhile; ?>
       ```
   
 *     ```
       <h2>Recent Posts</h2>
       <?php query_posts('orderby=date');?>
                              <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="recentpost"><hr width="600">
                               <img src="thumbnails/<?php echo get_post_meta($post->ID, "Thumbnail", true);?>">
                               <div class="leftrecent">
                               <h3><?php the_title();?></h3>
                               <?php the_excerpt();?><a href="<?php the_permalink()?>">Read More...</a>
                                     </div>
                               <div class="rightrecent">
                                     <span>Published: </span><?php the_time('F jS, Y') ?>
                                     <span>Author: </span><?php the_author() ?>
                                     <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
                                     <?php if(function_exists('the_views')) { the_views(); } ?>
                                     <span>Category: </span><?php the_category(', ');?>
                                     </div>
                               </div>
                               <?php endwhile; ?>
                               <?php endif; ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘query_posts’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [tom5436](https://wordpress.org/support/users/tom5436/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/query_posts-1/#post-817346)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
