Title: Loop help with nested categories
Last modified: August 19, 2016

---

# Loop help with nested categories

 *  Resolved [jcotter](https://wordpress.org/support/users/jcotter/)
 * (@jcotter)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/loop-help-with-nested-categories/)
 * Quick Q.. (i hope)..
 * I’ve got several nested categories from which i am including several (but not
   all) child categories as a “What’s New” section of my site. I’m trying to have
   it write a <p> tag prior to each loop, based on the child category.
 * Here’s what i’ve been trying to do:
 *     ```
       <?php query_posts /* enter # of posts here----> */('showposts=3&cat=15,27,28,29');/* For a full list of possible arguments you can pass to query_posts see http://codex.wordpress.org/Template_Tags/query_posts */
   
       global $more;    // Declare global $more (before the loop).
       $more = 0;       // Set (inside the loop) to display content above the more tag.
   
       ?>
   
       <ul>
       <?php while ( have_posts() ) : the_post(); ?>
       <li>
       <?php if (is_category('15')) { ?>
       <p class="category_leadin">Article Review:</p>
   
       <?php } elseif (is_category('27')) { ?>
       <p class="category_leadin">Book Review:</p>
   
       <?php } elseif (is_category('28')) { ?>
       <p class="category_leadin">Video Review:</p>
   
       <?php } elseif (is_category('29')) { ?>
       <p class="category_leadin">Website Review:</p>
   
       <?php } else { ?>
   
       <?php } ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
       <?php the_content('Read more...'); ?>
       </li>
       <?php endwhile; ?>
       </ul>
       ```
   
 * This is how it should ideally output:
 * Category name
    Title/link Content Read more…
 * [repeat loop]
 * Problem is, its only returning the parent category (in this case “Reviews”), 
   and not the child category )ex: “book reviews,” or “Site reviews.”
 * Does this make sense? Can anyone help me sort this out?
 * Thanks in advance for any insight you can offer.

Viewing 1 replies (of 1 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/loop-help-with-nested-categories/#post-1154179)
 * Well, you’re asking query_posts to only show 3 posts, so if the first 3 posts
   all happen to be in the Review category, that’s all you’ll get.

Viewing 1 replies (of 1 total)

The topic ‘Loop help with nested categories’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/loop-help-with-nested-categories/#post-1154179)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
