Title: Loop Trouble
Last modified: August 19, 2016

---

# Loop Trouble

 *  [rmaspero](https://wordpress.org/support/users/rmaspero/)
 * (@rmaspero)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/loop-trouble/)
 * I have two loops going on on my site one is in the header and is set to get 1
   post from the featured category and another that is set to get all post I don’t
   care if it has duplicates. Now this seems to work but when I get on to the single
   page I can’t comment and all the posts pages now have the featured post on them.
   I hope I did a good job of explaining here is the site so you can see better 
   [http://www.rmaspero.com/bloggingadventure](http://www.rmaspero.com/bloggingadventure).
 * and here is the code.
 * Header..
 * <?php query_posts(‘category_name=featured&showposts=1’); ?>
    <?php while (have_posts()):
   the_post(); ?> ” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute();?
   >”><div id=”featured-image”><?php the_meta(); ?> <div id=”featured-title”> Featured:
   <?php the_title() ?></div> </div>
 * <?php endwhile;?>
 * index….
 * <?php query_posts(‘cat=all’); ?>
 *  <?php if (have_posts()) : ?>
 *  <?php while (have_posts()) : the_post(); ?>
 *  <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2 class=”post-title”>” rel
   =”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title();?
   >
   </h2>
    <div id=”entry”> <?php the_content(‘Read the rest of this entry »’);?
   > </div> <div id=”meta-data”> Posted by <?php the_author() ?> at <?php the_time(‘
   F jS, Y’) ?> in <?php the_category(‘, ‘) ?> with the following tags : <?php the_tags(‘
   Tags: ‘, ‘, ‘, ‘‘); ?> </div> </div>
 *  <?php endwhile; ?>
 *  <div class=”next-previous”>
    <div><?php next_posts_link(‘« Older Entries’) ?
   ></div> <div><?php previous_posts_link(‘Newer Entries »’) ?></div> </div>
 *  <?php else : ?>
 *  <h2>Not Found</h2>
    <p>Sorry, but you are looking for something that isn’t here.
   </p> <?php include (TEMPLATEPATH . “/searchform.php”); ?>
 *  <?php endif; ?>
 * single….
 *  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 *  <div class=”navigation”>
    <div><?php previous_post_link(‘« %link’) ?></div> 
   <div><?php next_post_link(‘%link »’) ?></div> </div>
 *  <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”
   Permanent Link: <?php the_title_attribute(); ?>”><?php the_title(); ?>
   </h2>
 *  <?php the_content(‘<p class=”serif”>Read the rest of this entry »</p>’); ?>
 *  <?php wp_link_pages(array(‘before’ => ‘<p>**Pages:** ‘, ‘after’ => ‘</p>’, ‘
   next_or_number’ => ‘number’)); ?>
    <?php the_tags( ‘<p>Tags: ‘, ‘, ‘, ‘</p>’);?
   > </div> <p class=”postmetadata alt”> This entry was posted <?php /* This is 
   commented, because it requires a little adjusting sometimes. You’ll need to download
   this plugin, and follow the instructions: [http://binarybonsai.com/archives/2004/08/17/time-since-plugin/](http://binarybonsai.com/archives/2004/08/17/time-since-plugin/)*//*
   $entry_datetime = abs(strtotime($post->post_date) – (60*120)); echo time_since(
   $entry_datetime); echo ‘ ago’; */ ?> on <?php the_time(‘l, F jS, Y’) ?> at <?
   php the_time() ?> and is filed under <?php the_category(‘, ‘) ?>. You can follow
   any responses to this entry through the <?php comments_rss_link(‘RSS 2.0’); ?
   > feed.
 *  <?php if ((‘open’ == $post-> comment_status) && (‘open’ == $post->ping_status)){
   //
   Both Comments and Pings are open ?> You can [leave a response](https://wordpress.org/support/topic/loop-trouble/?output_format=md#respond),
   or ” rel=”trackback”>trackback from your own site.
 *  <?php } elseif (!(‘open’ == $post-> comment_status) && (‘open’ == $post->ping_status)){
   //
   Only Pings are Open ?> Responses are currently closed, but you can  ” rel=”trackback”
   >trackback from your own site.
 *  <?php } elseif ((‘open’ == $post-> comment_status) && !(‘open’ == $post->ping_status)){
   //
   Comments are open, Pings are not ?> You can skip to the end and leave a response.
   Pinging is currently not allowed.
 *  <?php } elseif (!(‘open’ == $post-> comment_status) && !(‘open’ == $post->ping_status)){
   //
   Neither Comments, nor Pings are open ?> Both comments and pings are currently
   closed.
 *  <?php } edit_post_link(‘Edit this entry.’,”,”); ?>
    </p>
 *  <?php comments_template(); ?>
 *  <?php endwhile; else: ?>
 *  <p>Sorry, no posts matched your criteria.</p>
 * <?php endif; ?>
 * any and all help is much appreciated

Viewing 1 replies (of 1 total)

 *  Thread Starter [rmaspero](https://wordpress.org/support/users/rmaspero/)
 * (@rmaspero)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/loop-trouble/#post-826388)
 * I have fixed it. It was because my query in the header would not closes here 
   is the correct code
 * header…
 *  <?php $my_query = new WP_Query(‘category_name=featured&showposts=1’);
    while(
   $my_query->have_posts()) : $my_query->the_post(); ?> ” rel=”bookmark” title=”
   Permanent Link to <?php the_title_attribute(); ?>”><div id=”featured-image”><?
   php the_meta(); ?> <div id=”featured-title”> Featured: <?php the_title() ?></
   div> </div> <?php endwhile; ?>
 * index…
 * just remove this line
 * <?php query_posts(‘cat=all’); ?>
 * should work fine.
 * My site link may not work in a few weeks time as I will be removing that site.

Viewing 1 replies (of 1 total)

The topic ‘Loop Trouble’ is closed to new replies.

## Tags

 * [content](https://wordpress.org/support/topic-tag/content/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [single](https://wordpress.org/support/topic-tag/single/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [rmaspero](https://wordpress.org/support/users/rmaspero/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/loop-trouble/#post-826388)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
