Title: Loop displaying different posts
Last modified: August 19, 2016

---

# Loop displaying different posts

 *  Resolved [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/)
 * This is the php code of my index page
 *     ```
       <?php query_posts('category_id=6&showposts=1'); ?>
       <?php $posts = get_posts('numberposts=1&offset=0'); foreach ($posts as $post) : start_wp(); ?>
       <?php static $count1 = 0; if ($count1 == "1") { break; } else { ?>
   
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       <?php echo get_the_image(array('Thumbnail','My Thumbnail'),'thumbnail'); ?>
       <?php the_excerpt(); ?>
   
       <?php $count1++; } ?>
       <?php endforeach; ?>
       <?php query_posts('category_id=6&showposts=5'); ?>
       <?php $posts = get_posts('numberposts=5&offset=2'); foreach ($posts as $post) : start_wp(); ?>
       <?php static $count2 = 0; if ($count2 == "5") { break; } else { ?>
   
       <?php echo get_the_image(array('Thumbnail','My Thumbnail'),'thumbnail'); ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
   
       <?php $count2++; } ?>
       <?php endforeach; ?>
   
        <?php query_posts($query_string . '&cat=-6'); ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
       			  <?php the_category(', ') ?>
       			   <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
       			   <?php echo get_the_image(array('Thumbnail','My Thumbnail'),'thumbnail'); ?>
                     <?php the_excerpt(); ?> 
   
       			   Objavljeno: <?php the_time('d.m.Y, G:i'); ?>
       			   <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">Ceo tekst &raquo;</a>
       			   <a href="<?php the_permalink() ?>#commenting" title="Komentari"><?php comments_number('0','1','%'); ?></a>
   
       			   <"clear1">
                      <!-- do stuff ... -->
                      <?php endwhile; ?>
       <?php endif; ?>
       ```
   
 * This is the part of code that is causing problems
 *     ```
       <?php query_posts('category_id=6&showposts=1'); ?>
       <?php $posts = get_posts('numberposts=1&offset=0'); foreach ($posts as $post) : start_wp(); ?>
       <?php static $count1 = 0; if ($count1 == "1") { break; } else { ?>
   
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       <?php echo get_the_image(array('Thumbnail','My Thumbnail'),'thumbnail'); ?>
       <?php the_excerpt(); ?>
   
       <?php $count1++; } ?>
       <?php endforeach; ?>
       <?php query_posts('category_id=6&showposts=5'); ?>
       <?php $posts = get_posts('numberposts=5&offset=2'); foreach ($posts as $post) : start_wp(); ?>
       <?php static $count2 = 0; if ($count2 == "5") { break; } else { ?>
   
       <?php echo get_the_image(array('Thumbnail','My Thumbnail'),'thumbnail'); ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
   
       <?php $count2++; } ?>
       <?php endforeach; ?>
       ```
   
 * On localhost it works fine. It’s shows 1 and 5 posts from category with id 6.
 * When i transfered this theme to my host and activated it, it shows posts from
   category with id 11.
 * How is that possible?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/#post-1366073)
 * Not sure why you need the query_posts statements and you might use setup_postdata()
   rather than start_wp().
 * One example:
    [http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/](http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/#post-1366079)
 * [http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters](http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters)
   ‘
   category_id=6’ does not seem to be a correct argument;
 *     ```
       <?php query_posts('category_id=6&showposts=1'); ?>
       ```
   
 * could be:
 *     ```
       <?php query_posts('cat=6&posts_per_page=1'); ?>
       ```
   
 *  Thread Starter [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/#post-1366118)
 * [@michaelh](https://wordpress.org/support/users/michaelh/)
    I took the code from
   here: [http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/](http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/)
 * [@alchymyth](https://wordpress.org/support/users/alchymyth/)
    I tried changing
   my code to one you suggested, but still the same… The problem is THAT IT SHOWS
   THE LATEST POSTS added to the blog, regardless of the category.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/#post-1366130)
 * i have the feeling that ‘get_posts()’ does not care about the ‘query_posts()’;
   
   you could probably add the category id to the get_posts() as it uses the same
   parameter as query_posts(); [http://codex.wordpress.org/Template_Tags/get_posts#Parameters:_WordPress_2.6.2B](http://codex.wordpress.org/Template_Tags/get_posts#Parameters:_WordPress_2.6.2B)
 *  Thread Starter [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/#post-1366142)
 * alchymyth, thanks a bunch…
 * It works now (i think).

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

The topic ‘Loop displaying different posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [djuradj](https://wordpress.org/support/users/agent001/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/loop-displaying-different-posts/#post-1366142)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
