title: Wordpress display all posts under specific category
body: <p>I am trying to display all posts under a child child category. But my code keep rendering Parent category then all the post, then child and all the posts. I keep getting more categories the I want. This sidebar is used in single.php only.</p>
  
  <p>My category structure looks like this.</p>
  
  <ul>
  <li>Parent
  <ul>
  <li>Child 1
  <ul>
  <li>Child-Child 1.1</li>
  <li>Child-Child 1.2</li>
  </ul></li>
  <li>Child 2
  <ul>
  <li>Child-Child 2.2</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Under Child-child I have posts, how I would like to render it.</p>
  
  <pre><code>&lt;div id="child-child-title"&gt;
      &lt;ul&gt;
          &lt;li class="post"&gt;title + post meta data&lt;/li&gt;
          &lt;li class="post"&gt;title + post meta data&lt;/li&gt;
          &lt;li class="post"&gt;title + post meta data&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is what I am working with, and it is rendering every category (either if it's a parent or child) and every post on the site under it. </p>
  
  <pre><code>&lt;?php global $post; $categories = get_the_category();foreach ($categories as $category) : ?&gt;
  &lt;h4&gt;&amp;raquo; &lt;?php echo $category-&gt;name; ?&gt;&lt;/h4&gt;
  &lt;ul&gt;
  
  &lt;?php
  foreach((get_the_category()) as $category) {
      $cat_ids=$cat_ids . $category-&gt;cat_ID . ',';
  }
  $cat_ids=substr($cat_ids, 0, -1);
  //----------
  ?&gt;
  
  &lt;?php $posts = get_posts('numberposts=20&amp;amp;category='. $cat_ids);foreach($posts as $post) : ?&gt;
  &lt;a href='&lt;?php the_permalink() ?&gt;'&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;br&gt;
  &lt;?php endforeach; ?&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href="&lt;?php echo get_category_link($category-&gt;term_id);?&gt;"&gt;&lt;?php echo $category-&gt;name; ?&gt; &lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
  &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>