Two queries on same page
-
This is my second topic about this. The first I thought was working and closed it as resolved. link
What I am trying to do is break the index into two sections. The first displays the most recent post in category 3 and the second section displays the most recent post in categories 5,25,21,26,19,10,27,29, or 24.
I don’t update the second section as much. I have made several posts to category 3 in the last week and they display correctly.
Today I make a post to category 26. It displayed in the first section instead of the second and nothing displayed in the second section.
I am guessing there is some problem with my queries. I took the code from a post I found on the forums here.
<font size="5">Latest Blog Entry</font> <!-- begin news loop --> <?php $my_query = new WP_Query('category=3&showposts=1'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> <small>By <?php the_author() ?> | <?php the_time('F j, Y'); ?> <?php edit_post_link('(edit)'); ?></small> <div class="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> <p class="postmetadata"><?php the_tags('Tags: ', ', ', '.'); ?> Read more from <?php the_category(', ') ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> </div> <?php endwhile; ?> <!-- end news loop --> <font size="5">Latest Story</font> <!-- begin story loop --> <?php query_posts('cat=5,25,21,26,19,10,27,29,24&showposts=1'); ?> <?php while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> <small>By <?php the_author() ?> | <?php the_time('F j, Y'); ?> <?php edit_post_link('(edit)'); ?></small> <div class="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> <p class="postmetadata"><?php the_tags('Tags: ', ', ', '.'); ?> Read more from <?php the_category(', ') ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> </div> <?php endwhile; ?> <!-- end story loop -->Anyone know what I did wrong?
The topic ‘Two queries on same page’ is closed to new replies.