title: How can I show a list of parent categories and their sub category posts
body: <p>I need to show lists in this order.. parent-sub-category-title => sub-category-title => sub-category posts. The following code gets me the parent title but doesn't give me the posts. Can anyone tell me why?</p>
  
  <p>parent category title</p>
  
  <p>sub-category title</p>
  
  <p>sub-category-post</p>
  
  <pre><code>    //get all categories then display all posts in each term
      $taxonomy = 'commongood-categories'; //change this name if you have taxonomy
      $param_type = 'category__in';
      $term_args=array(
      'orderby' =&gt; 'name',
      'order' =&gt; 'ASC'
      );
      $terms = get_terms($taxonomy,$term_args);
      if ($terms) {
  
          foreach($terms as $term){ //this foreach is for top level
          if($term-&gt;parent == 0){
          echo '&lt;h2&gt;'.$term-&gt;name.' &lt;/h2&gt;'; //get top level category name
          $term_args=array(
          'orderby' =&gt; 'name',
          'order' =&gt; 'ASC',
          'child_of' =&gt; $term-&gt;term_id
  
           );
  
          $termss = get_terms($taxonomy,$term_args);
          foreach( $termss as $terms ) { 
          $args=array(
              "$param_type" =&gt; array($terms-&gt;term_id),
              'post_type' =&gt; 'commongood',
              'post_status' =&gt; 'publish',
              'posts_per_page' =&gt; -1,
              'caller_get_posts'=&gt; 1
  
              );
  
  
              $my_query = new WP_Query($args);
  
              &lt;?php while ( $my_query-&gt;have_posts() ) : $my_query-&gt;the_post(); ?&gt;
                  &lt;li class="series-bubble"&gt;
                  &lt;div class="stext"&gt;
                      &lt;span class="stitle"&gt;&lt;a href="&lt;?php echo get_permalink(); ?&gt;"&gt;&lt;?php if(get_field('optional_title')) { echo get_field('optional_title'); } else echo get_the_title(); ?&gt;&lt;/a&gt;&lt;/span&gt;
                      &lt;span class="scontent"&gt;&lt;a href="&lt;?php echo get_permalink(); ?&gt;"&gt;&lt;?php echo get_the_excerpt(); ?&gt;&lt;/a&gt;&lt;/span&gt;
                  &lt;/div&gt;  
                  &lt;/li&gt;
              &lt;?php endwhile;
  
             }
           }
         }
       }
  </code></pre>