Title: Help with multiple loops
Last modified: August 18, 2016

---

# Help with multiple loops

 *  [stuboo](https://wordpress.org/support/users/stuboo/)
 * (@stuboo)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/help-with-multiple-loops/)
 * I’m definately a php novice but would like to display a loop within a loop.
 * My main post page looks like this
 * `<?php get_header(); ?>
    <div id="wrapper" class="clearfix" >  <div id="gencol"
   ><?php if (have_posts()) : while (have_posts()) : the_post();?> <h2 id="post-
   <?php the_ID(); ?>"><?php the_title();?></h2> <?php  include 'wp-content/themes/
   laca/whichnewsletter.inc.php'; the_content('<p>Read the rest of this page &raquo;
   </p>'); ?> <?php endwhile; endif; include 'wp-content/themes/laca/viewothers.
   inc.php'; ?>  <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div
   > <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
 * And my whichnewsletter.inc.php looks like this
 * `<?php
    // Let's make that thing that says "This article appears in the xx newsletter"//
   Fall 2003 if (in_category('12')){?> <p id="whichnewsletter">This article appears
   in the <a href="?cat=12">Fall 2003 Newsletter</a></p> <?php } // Spring 2004 
   if (in_category('13')){?> <p id="whichnewsletter">This article appears in the
   <a href="?cat=13">Spring 2004 Newsletter</a></p> <?php } // Fall 2004 if (in_category('
   14')){?> <p id="whichnewsletter">This article appears in the <a href="?cat=14"
   >Fall 2004 Newsletter</a></p> <?php } // Spring 2005 if (in_category('15')){?
   > <p id="whichnewsletter">This article appears in the <a href="?cat=15">Spring
   2005 Newsletter</a></p> <?php } // Fall 2005 if (in_category('16')){?> <p id="
   whichnewsletter">This article appears in the <a href="?cat=16">Fall 2005 Newsletter
   </a></p> <?php } // Spring 2006 if (in_category('17')){?> <p id="whichnewsletter"
   >This article appears in the <a href="?cat=17">Spring 2006 Newsletter</a><br /
   > <a href="javascript:toggleLayer('articles');">view all articles from this newsletter
   </a></p> <?php } // Fall 2006 if (in_category('18')){?> <p id="whichnewsletter"
   >This article appears in the <a href="?cat=18">Fall 2006 Newsletter</a></p> <?
   php }
 * Basically, I want to show a list of all articles within the specified category
   on a single post page. I tried using this code in the whichnewsletter.inc.php
   file but it causes the wrong content to be pulled from the first loop.
 * `<div id="articles">
    <ul> <?php query_posts('category=17'); while(have_posts()):
   the_post(); ?> <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="
   Permalink to <?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile;?
   > </ul> </div>
 * I hope I’m being clear. Thanks in advance for your help.
    Ryan

Viewing 1 replies (of 1 total)

 *  Thread Starter [stuboo](https://wordpress.org/support/users/stuboo/)
 * (@stuboo)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/help-with-multiple-loops/#post-482635)
 * bump

Viewing 1 replies (of 1 total)

The topic ‘Help with multiple loops’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [stuboo](https://wordpress.org/support/users/stuboo/)
 * Last activity: [19 years, 7 months ago](https://wordpress.org/support/topic/help-with-multiple-loops/#post-482635)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
