• Resolved schultzy

    (@schultzy)


    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 &raquo;'); ?>
    			</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 &raquo;'); ?>
    			</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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter schultzy

    (@schultzy)

    Anyone have any ideas?

    Looking over them I see nothing wrong with your queries. You’re positive this “post to category 26” was not also somehow assigned to category 3?

    I assume if you remove:

    if( $post->ID == $do_not_duplicate ) continue;

    from your latter query, the post displays?

    Thread Starter schultzy

    (@schultzy)

    That was one of the first things I checked. And if I remove that line, I get PHP errors. It is probably one of the plugins I am using since I have about a dozen running.
    I appreciate the help though. I actually I am going to change themes and re-order things so I am going to close this as resolved.

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

The topic ‘Two queries on same page’ is closed to new replies.