Title: My second loop doesn&#8217;t work
Last modified: August 18, 2016

---

# My second loop doesn’t work

 *  Resolved [ganzua](https://wordpress.org/support/users/ganzua/)
 * (@ganzua)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/)
 * Hi there!
 * I created a template for a page (wp static page) with two loops. The first loop
   will show the last post of the blog. The second loop will show the content of
   the page.
 * The first loop code goes like this;
 * <?php query_posts(‘posts_per_page=1’); ?>
    <?php if (have_posts()) : ?> <?php
   while (have_posts()) : the_post(); ?>
 * <div…
 * <?php the_content()
    <?php endwhile; ?>
 * –> so far so good, it works! but then I insert the second loop and it doesn’t
   work. I must be missing anything;
 * <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”
   post” id=”post-<?php the_ID(); ?>”> <h2><?php the_title(); ?></h2> <div class
   =”entrytext”> <?php the_content(‘<p class=”serif”>read »’); ?>
 * <?php link_pages(‘**Paginas:** ‘, ”, ‘number’); ?>
 * </div>
    </div> <?php endwhile; endif; ?> <?php edit_post_link(‘Edit.’, ”, ”);?
   >
 * –> What I’m doing wrong? I have read I need to re-set the second loop but not
   sure how to do it?
 * Please, help!

Viewing 6 replies - 16 through 21 (of 21 total)

[←](https://wordpress.org/support/topic/my-second-loop-doesnt-work/?output_format=md)
[1](https://wordpress.org/support/topic/my-second-loop-doesnt-work/?output_format=md)
2

 *  Thread Starter [ganzua](https://wordpress.org/support/users/ganzua/)
 * (@ganzua)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270057)
 * Ok, here is the header; (hope it works);
 * [http://90plan.ovh.net/~covenmys/header.txt](http://90plan.ovh.net/~covenmys/header.txt)
 * By the way, I just realized that the site is not compatible with firefox at all,
   it seems firefox is not loading wordpress sidebar.
 *  [nearlythere](https://wordpress.org/support/users/nearlythere/)
 * (@nearlythere)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270077)
 * i quickly scanned that file, and noted that you have two comments in your file,
   but one is not closed. look for the comment which does not close:
 * `<!-- Index inicio`
    `Page template`
 * you need to close this with:
    `-->`
 * i also noted that on your [page](http://90plan.ovh.net/~covenmys/wordpress/?page_id=3)
   i see a stray end of comment line here:
 * Archivos
    * Octubre 2005 `-->`
 * i’m not entirely sure if this will solve your problem, but can you fix that comment
   by closing it `-->` and run the code and come back to tell us how it came along?
 *  Thread Starter [ganzua](https://wordpress.org/support/users/ganzua/)
 * (@ganzua)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270093)
 * Thanks nearlythere, it is very kind of you.
 * In the header I commented the second loop because it wasn’t working and I wanted
   to try the query_posts(‘page_id=3’)tag.
 * The second one; * Octubre 2005 comes from the sidebar. I commented this one to
   stop showing archives in the sidebar.
 * I checked them with my php editor and I think the commented lines are ok, all
   of them appear in grey.
 *  [nearlythere](https://wordpress.org/support/users/nearlythere/)
 * (@nearlythere)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270099)
 * sorry, ganzua i don’t understand then. you said your “second loop doesn’t work”
 * still looks to me like an open HTML comment!
 * this is what i see: i see two loops, preceded by two queries:
 * first:
    `<?php query_posts('posts_per_page=1'); ?>`
 * second:
    `<?php query_posts('page_id=3');  ?>
 * and the second one is ‘hidden’ inside an unclosed HTML comment tag. and if i 
   look at the HTML source, the code was still ‘run’ but it isn’t appearing, because
   it is hidden in HTMl comment.
 *  `<!-- Index inicio
    Page template
 *  `<div class="post" id="post-3">
    <h2>Inicio</h2> <div class="entrytext"> Ut 
   wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis
   nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit
   in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla
   facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent
   luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber
   tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod
   mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing
   elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
   erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
   suscipit lobortis nisl ut aliquip ex ea commodo consequat.
 *  `</div>`
    `</div>`
 *  `<!-- Index inicio`
    `Page template -->`
 * so after the first:
 *  `<!-- Index inicio
    Page template
 * you **need** to close the comment. and it should look like this:
    `<!-- Index
   inicio Page template -->
 * i don’t mind where you do it, but you have to close it somewhere. that’s about
   as clear as i can make it.
 * if this isn’t the solution to your problem, sorry i can’t help further!
 *  Thread Starter [ganzua](https://wordpress.org/support/users/ganzua/)
 * (@ganzua)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270107)
 * Hey nearlythere!
 * I’m back. I got it working now! You were right; query_posts(‘page_id=3’) plus
   the second loop worked. I had it commented because I thought all what I needed
   was the query_posts(‘page_id=3’) with no loop behind.
 * Thank you very much for your help and good luck with your japanese.
 * ä¼šã?„ã?ªã?•ã?„ ?
 *  [nearlythere](https://wordpress.org/support/users/nearlythere/)
 * (@nearlythere)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270110)
 * *phew* i’m glad that worked out!
 * æ—¥æœ¬èªžã?Œã?§ã??ã?¾ã?™ã?‹ï¼Ÿ
    not that i can! but i’m trying 🙂

Viewing 6 replies - 16 through 21 (of 21 total)

[←](https://wordpress.org/support/topic/my-second-loop-doesnt-work/?output_format=md)
[1](https://wordpress.org/support/topic/my-second-loop-doesnt-work/?output_format=md)
2

The topic ‘My second loop doesn’t work’ is closed to new replies.

## Tags

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

 * In: [Installing WordPress](https://wordpress.org/support/forum/installation/)
 * 21 replies
 * 6 participants
 * Last reply from: [nearlythere](https://wordpress.org/support/users/nearlythere/)
 * Last activity: [20 years, 7 months ago](https://wordpress.org/support/topic/my-second-loop-doesnt-work/page/2/#post-270110)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
