Title: 4 Loops On Single.php
Last modified: August 19, 2016

---

# 4 Loops On Single.php

 *  [Joe Hall](https://wordpress.org/support/users/redbmedia/)
 * (@redbmedia)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/4-loops-on-singlephp/)
 * Hey there,
 * I am trying to create a single.php template for a theme. This template displays
   a lot of loops in different locations. Below you can see 4 simple loops that 
   I am trying to implement on this template. All of the loops work great. However
   the second loop loops through all of the post when trying to visit a single post
   page. I want this loop to only post the post that is selected. I tried using 
   rewind_posts() but that doesn’t seem to be working. Does anyone have any ideas?
 *     ```
       <?php rewind_posts(); ?>
       <?php query_posts('category_name=video&showposts=100'); ?>
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <p><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></p>
       <p><?php the_excerpt(); ?></p>
       <hr />
       <?php endwhile; ?>
       <?php endif; ?>	
   
       <?php rewind_posts(); ?>
       <?php while (have_posts()) : the_post(); ?>
       <?php the_content(); ?>
       <?php endwhile; ?>
   
       <?php rewind_posts(); ?>
       <?php query_posts('category_name=video&showposts=5'); ?>
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <a href="<?php the_permalink() ?>" class="recent_link"  title="Permanent Link to <?php the_title(); ?>">>&nbsp;&nbsp;<?php the_title(); ?></a>
       <?php endwhile; ?>
       <?php endif; ?>
   
       <?php query_posts('showposts=6'); ?>
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <a href="<?php the_permalink() ?>" class="recent_link" title="Permanent Link to <?php the_title(); ?>">>&nbsp;&nbsp;<?php the_title(); ?></a>
       <?php endwhile; ?>
       <?php endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/4-loops-on-singlephp/#post-1200612)
 * Might consider this approach (get_posts)
 * [http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/](http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/)

Viewing 1 replies (of 1 total)

The topic ‘4 Loops On Single.php’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [single](https://wordpress.org/support/topic-tag/single/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/4-loops-on-singlephp/#post-1200612)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
