Title: Multiple Complicated Loops
Last modified: August 19, 2016

---

# Multiple Complicated Loops

 *  Resolved [kennethwatt](https://wordpress.org/support/users/kennethwatt/)
 * (@kennethwatt)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-complicated-loops/)
 * Hi guys
 * I have a div section at the top of a page, and then another one below, and I 
   want the top one to display a list of 6 titles of all posts, except ones in category
   13. Also, how do you end this loop.
    I so far have for this div section:
 *     ```
       <?php if (have_posts(3)) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
       <?php endwhile; ?>
       ```
   
 * I also want the second div section to display a list of 10 posts (I have the 
   code required to go in between the loop stuff)in all categories except in the
   featured category. Likewise, how should I go about ending this loop.
    I so far
   have for this:
 *     ```
       <?php if (have_posts()) : ?>
       			<?php while (have_posts()) : the_post(); ?>
       				<div class="post" id="post-<?php the_ID(); ?>">
       					<div class="postwrapper">
       						<a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading the rest of this entry »"><img src="<?php $key="thumbnail"; echo get_post_meta($post->ID, $key, true); ?>" alt="thumbnail" class="thumbnail" /></a>
       						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
       						<div class="entry">
       							<?php the_excerpt(); ?>
       						</div>
       					</div>
       					<div class="postmetadata">
       						<span class="thetime"><?php the_time('F jS, Y') ?></span>
       						<span class="thecategory"><?php the_category(', ') ?></span>
       						<?php edit_post_link('Edit', '<span class="editthispost">', '</span>'); ?>
       						<span class="thecomments"><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></span>
       						<div class="readmore">
       							<a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading the rest of this entry »">Read More</a>
       						</div>
       					</div>
       				</div>
   
       		<?php endwhile; ?>
   
       				<div class="navigation">
       					<div class="navleft"><?php next_posts_link('Older Entries') ?></div>
       					<div class="navright"><?php previous_posts_link('Newer Entries') ?></div>
       				</div>
   
       	<?php else : ?>
   
       		<h2 class="center">Not Found</h2>
       		<p class="center">Sorry, but you are looking for something that isn't here.</p>
       		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
   
       	<?php endif; ?>
       ```
   
 * Any help would be much appreciated
 * Kenneth

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-complicated-loops/#post-1044987)
 * You might want to read up on Multiple Loops:
 * [http://codex.wordpress.org/The_Loop#Multiple_Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)
 *  Thread Starter [kennethwatt](https://wordpress.org/support/users/kennethwatt/)
 * (@kennethwatt)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-complicated-loops/#post-1044993)
 * Thanks Esmi, but for the following two pieces of code, how can I say how many
   posts to show, as it just uses the default from the Reading section of the WP
   Settings.
 *     ```
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       ```
   
 * and
 *     ```
       <?php if (have_posts()) : ?>
       			<?php while (have_posts()) : the_post(); ?>
       ```
   
 * Thanks
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-complicated-loops/#post-1045140)
 * [query_posts](http://codex.wordpress.org/Template_Tags/query_posts) with the `
   showposts` parameter?

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

The topic ‘Multiple Complicated Loops’ is closed to new replies.

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-complicated-loops/#post-1045140)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
