• Hello
    the problem is that I have this 3 loops in index.php. The firts one is a featured post, the second one is a for category 1, and the other is for the others categories. I want the feaured and the cat 1 in the home and exclude the others categories that is way i use the query_post in first place, and use the codex that I learned in the www.remarpro.com (the loop). But this give me a featured post that appears in every category. But I need that featured category to appear only in the home. The questions are :
    I’m doing something wrong???
    Is this the code that I need???
    What I have to change, how???

    I now that are many questions but please help me and forgive my ignorance.
    Thank in advance.

    This is basically the code of index.php.

    <?php if ( is_home() ) {
    query_posts('cat=1');
    }
    ?>
    
    <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
    <!-- 1 loop Featured -->
    
      <?php endwhile; ?>
    
       <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts);  ?>
    
     <?php if ( in_category('1') ) { ?>
    
    <!-- 2 loop -->
    
    <?php } else { ?>
    
    <!--3 loop -->

  • The topic ‘Help with query in loop’ is closed to new replies.