Title: two query posts on same page
Last modified: August 19, 2016

---

# two query posts on same page

 *  [acmc](https://wordpress.org/support/users/acmc/)
 * (@acmc)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/two-query-posts-on-same-page/)
 * On my content template for a portion of the content I utilize the following
    
   <div id=”content_info”> <?php $temp_query = $wp_query; ?> <?php if (is_page(’
   21’) ) { ?> <?php query_posts(‘p=27’); ?>
 *  <?php while (have_posts()) : the_post(); ?>
    <h4><?php the_title(); ?></h4> 
   <?php the_content(); ?> </div> <?php endwhile; } elseif (is_page(’22’) ) { ?>
 *  <?php query_posts(‘p=31’); ?>
    <?php while (have_posts()) : the_post(); ?> <
   h4><?php the_title(); ?></h4> <?php the_content(); ?>
 *  <?php endwhile;
    } elseif (is_page(’23’) ) { ?> <?php query_posts(‘p=36’); ?
   >
 *  <?php while (have_posts()) : the_post(); ?>
    <h4><?php the_title(); ?></h4> 
   <?php the_content(); ?>
 *  <?php endwhile;
    } elseif (is_page(’24’) ) { ?> <?php query_posts(‘p=40’); ?
   >
 *  <?php while (have_posts()) : the_post(); ?>
    <h4><?php the_title(); ?></h4> 
   <?php the_content(); ?>
 *  <?php endwhile;
    } else { ?> //whatever goes in here <?php } ?> </div>
 * Works great
    then in another section of content I place <div id=”content_comments’
   > <?php global $more; $more = 0; ?> <?php $temp_query = $wp_query; ?>
 *  <?php query_posts(‘cat=24&showposts=1’); ?>
 *  <?php while (have_posts()) : the_post(); ?>
 *  <div class=”post” id=”post-<?php the_ID(); ?>”> </div>
 * </h3>
 *  <div id=”blog-entry-message”><?php the_content(‘[…]’); ?></div>
    <?php endwhile;?
   > </div>
 * and the thing breaks – by break – the second portion works – it shows the correct
   post, but the first set of content goes to the
    } else { ?> //whatever goes in
   here response.
 * I am at a loss. Not a php programmer, playing around – probably a silly syntax
   error. But any help would be greatly appreciated. I have double checked the page
   category and post id numbers and they are all correct… help

Viewing 1 replies (of 1 total)

 *  Thread Starter [acmc](https://wordpress.org/support/users/acmc/)
 * (@acmc)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/two-query-posts-on-same-page/#post-885862)
 * never mind – i think i found the answer – although I don’t know the why – moved
   the divs aroun (order on the page) put the second before the first and presto–
   it works… If someone could enlighten me to why that would be neato;-)

Viewing 1 replies (of 1 total)

The topic ‘two query posts on same page’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [acmc](https://wordpress.org/support/users/acmc/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/two-query-posts-on-same-page/#post-885862)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
