title: How to hide empty subcategories (WordPress)
body: <p>I am using the code below which show empty subcategories also which don't have any post in it and I want to hide these. Let me if it is possible and if yes then how</p>
  
  <pre><code>&lt;?php
      $term = get_queried_object();
      $term_id = $term-&gt;term_id;
      $taxonomy_name = $term-&gt;taxonomy;
  
      $termchildren = get_term_children( $term_id, $taxonomy_name );
  
      echo '&lt;ul&gt;';
      foreach ( $termchildren as $child ) {
          $term = get_term_by( 'id', $child, $taxonomy_name );
          echo '&lt;li&gt;&lt;a href="' . get_term_link( $term, $taxonomy_name ) . '"&gt;' . $term-&gt;name.' ('. $term-&gt;count. ')&lt;/a&gt;&lt;/li&gt;';
      }
      echo '&lt;/ul&gt;';
  ?&gt;
  </code></pre>
  
  <p>Thanks a lot in advance</p>