Title: multiple &quot;the Loop&quot; not showing second posts
Last modified: August 20, 2016

---

# multiple "the Loop" not showing second posts

 *  Resolved [miowebdesigns](https://wordpress.org/support/users/miowebdesigns/)
 * (@miowebdesigns)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/)
 * I am using the loop twice on my index page. Once like this:
 * _[Code moderated per forum rules – please follow [http://codex.wordpress.org/Forum\_Welcome#Posting\_Code](http://codex.wordpress.org/Forum_Welcome#Posting_Code)
   for posting code]_
 * The problem is that I get the results I am looking for on the first loop but 
   the second one is blank. No results. I tried the same thing using query_posts(“
   posts_per_page=2”); with a wp_reset_query(); between but the results were the
   same. When I left out the post_per_page on the second loop the first loop is 
   fine but the second loop shows all posts with no end. Anything?

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

 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238438)
 * Try using a custom query loop on the 2nd loop
 * [http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/](http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/)
 *  Thread Starter [miowebdesigns](https://wordpress.org/support/users/miowebdesigns/)
 * (@miowebdesigns)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238497)
 * You can’t see it because the code didn’t appear but that is exactly what I am
   doing.
 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238498)
 * you can paste your full code in a paste bin if you want
 *  Thread Starter [miowebdesigns](https://wordpress.org/support/users/miowebdesigns/)
 * (@miowebdesigns)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238501)
 * Maybe this will show up.
 *     ```
       <!-- Start the Loop. -->
       			<?php
       			    $myquery = new WP_Query();
       			    $myquery->query('showposts=2');
       			?>
       			<?php
       			while ($myquery->have_posts()) : $myquery->the_post();
       			?>
   
       			<?php if ( in_category('projects') ) { ?>
       					 <li>
       					   <div id="homepage_projects_text" class="group">
       						<div class="home_projects_image">
       					<?php if(has_post_thumbnail()) {  ?>
       					<?php the_post_thumbnail('thumbnail');?>
       						<?php } else { ?>
       					<img src="<?php bloginfo('template_url'); ?>/images/no_image.png" alt="no image available"/>
       					<?php } ?>
       					    </div>
       					      <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
       				          <p><?php the_excerpt(); ?></p>
       					 </div>
       				    </li>
       						 <?php } ?>
   
       			<?php endwhile; ?>
       ```
   
 *     ```
       <!-- Start the Loop. -->
       	<?php
       	    $anotherquery = new WP_Query();
       	    $anotherquery->query('showposts=2');
       	?>
       	<?php
             while ($anotherquery->have_posts()) : $anotherquery->the_post();
       	?>
       	    <?php if ( in_category('blog') ) { ?>
       		       <li>
       				 <div id="blog_title">
       		         <div class="blog_date"><?php the_date(); ?></div>
       		           <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>
       		           <p><?php the_excerpt(); ?></p>
       		       </li>
       		<?php } ?>
   
       	<?php endwhile; ?>
       ```
   
 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238504)
 * Hi
 * The main problem you are having is it is selecting two posts in the second query,
   and since they are not in the blog category its not displaying them. You need
   to move the category selector into the query parameters
 * second loop:
 *     ```
       <?php
       	    $anotherquery = new WP_Query();
       	    $anotherquery->query('showposts=2&category_name=blog');
       	?>
       	<?php
             while ($anotherquery->have_posts()) : $anotherquery->the_post();
       	?>
       		       <li>
       				 <div id="blog_title">
       		         <div class="blog_date"><?php the_date(); ?></div>
       		           <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>
       		           <p><?php the_excerpt(); ?></p>
       		       </li>
       	<?php endwhile; ?>
       ```
   
 * its better to use posts_per_page as showposts is now deprecated – they do the
   same thing
 *  Thread Starter [miowebdesigns](https://wordpress.org/support/users/miowebdesigns/)
 * (@miowebdesigns)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238505)
 * Thank you, thank you …That was it.
 *  Thread Starter [miowebdesigns](https://wordpress.org/support/users/miowebdesigns/)
 * (@miowebdesigns)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238516)
 * One small issue if that the date is not showing up after the first post.
 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238527)
 * I’m not seeing anything in the code that prevents the date from showing up in
   the second post. Check the browser source code and see if the div in
    `<div class
   ="blog_date"><?php the_date(); ?></div>` appears. If not, you have to determine
   why not.

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

The topic ‘multiple "the Loop" not showing second posts’ is closed to new replies.

## Tags

 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * In: [Installing WordPress](https://wordpress.org/support/forum/installation/)
 * 8 replies
 * 2 participants
 * Last reply from: [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/multiple-the-loop-not-showing-second-posts/#post-2238527)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
