• 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)
Viewing 1 replies (of 1 total)
  • The topic ‘4 Loops On Single.php’ is closed to new replies.