Title: Page title changes when using multiple loops?
Last modified: August 19, 2016

---

# Page title changes when using multiple loops?

 *  [ben_allison](https://wordpress.org/support/users/ben_allison/)
 * (@ben_allison)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/)
 * I’m using two loops on the same page. No big deal.
 * But now my tag, “<?php the_title(); ?>” doesn’t show the page of the title. Instead,
   it shows the title of the last post being displayed.
 * For fun, I tried moving the tag to before the first loop, and the title went 
   back to normal. It seems like some variable somewhere is not getting cleared 
   or reset…
 * Ideas?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/#post-1307340)
 * What are you using for you 2 Loops – get_posts or query_posts?
 *  Thread Starter [ben_allison](https://wordpress.org/support/users/ben_allison/)
 * (@ben_allison)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/#post-1307347)
 * query_posts. Here are the two loops:
 * **This one gets Post Thumbnails (I’m using 2.9 beta)**
 *     ```
       <?php query_posts('showposts=5'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <li>
       <?php the_post_image('full'); ?>
       </li>
       <?php endwhile;?>
       ```
   
 * **This one for excerpts**
 *     ```
       <?php query_posts('showposts=5'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <li><a href="<?php the_permalink() ?>"><h2><?php the_title(); ?> | <?php the_time('m.j.y') ?></h2><?php the_excerpt(); ?></a></li>
       <?php endwhile;?>
       ```
   
 * So with this code, I’m able to have post thumbnails in one div, excerpts in another.
 *  Thread Starter [ben_allison](https://wordpress.org/support/users/ben_allison/)
 * (@ben_allison)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/#post-1307592)
 * Bump for an answer!
 *  Thread Starter [ben_allison](https://wordpress.org/support/users/ben_allison/)
 * (@ben_allison)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/#post-1307596)
 * The problem even happens when using one loop on a page, but where the the_title
   tags comes well after the end of the loop, and this time, I’m using a secondary
   loop.
 *     ```
       <?php
       	$childProjects = new WP_Query();
       	$childProjects->query('post_type=pagepost_parent='.$post->ID);
       ?>
       <?php
       	while ($childProjects->have_posts()) : $childProjects->the_post();
       ?>
       <li>
       <?php
       	get_the_image( array('default_size' => 'full', 'link_to_post' => false) ); ?>
       </li>
       <?php endwhile;?>
   
       <h1><?php the_title(); ?></h1>
       ```
   
 *  Thread Starter [ben_allison](https://wordpress.org/support/users/ben_allison/)
 * (@ben_allison)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/#post-1307599)
 * lol
 * THANKS EVERYONE!
 * I found the answer. I had to reset the queue, to make sure it was dead.
 *     ```
       <?php wp_reset_query(); ?>
       ```
   
 * This goes for other things too, like if you’re calling a post_thumbnail for the
   page after a have a loop that is collecting posts. The post_thumbnail for the
   last image will be called instead, unless you reset the query.

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

The topic ‘Page title changes when using multiple loops?’ is closed to new replies.

## Tags

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

 * 5 replies
 * 2 participants
 * Last reply from: [ben_allison](https://wordpress.org/support/users/ben_allison/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/page-title-changes-when-using-multiple-loops/#post-1307599)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
