Support » Fixing WordPress » 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 id=”blog-entry-title”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></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

    (@acmc)

    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.