title: custom category tree in wordpress
body: <p>Hi i want to create a tree of categories in wordpress like this : </p>
  
  <pre><code>&lt;ul&gt;
      &lt;a href=""&gt; PARENT1 &lt;/a&gt;
      &lt;li&gt;&lt;a href=""&gt; CHILD 1-1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=""&gt; CHILD 1-2&lt;/a&gt;&lt;/li&gt;
       .
       .
       .
  &lt;/ul&gt;
  &lt;ul&gt;
      &lt;a href=""&gt; PARENT2 &lt;/a&gt;
      &lt;li&gt;&lt;a href=""&gt; CHILD 2-1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=""&gt; CHILD 2-2&lt;/a&gt;&lt;/li&gt;
       .
       .
       .
  &lt;/ul&gt;
  </code></pre>
  
  <p>i want something that creates categories list in above format and show only categories which have children and hide those who don't </p>
  
  <p>I Tried Something like this but it didn't give me what i wanted</p>
  
  <pre><code>&lt;?php $args = array(
  'type'                     =&gt; 'post',
  'child_of'                 =&gt; 0,
  'parent'                   =&gt; '',
  'orderby'                  =&gt; 'name',
  'order'                    =&gt; 'ASC',
  'hide_empty'               =&gt; 0,
  'hierarchical'             =&gt; 1,
  'exclude'                  =&gt; '',
  'include'                  =&gt; '',
  'number'                   =&gt; '',
  'taxonomy'                 =&gt; 'category',
  'pad_counts'               =&gt; false 
  );
  $cats = get_categories( $args );
  foreach( $cats as $cat) {
      if($cat-&gt;parent == 0) {
          $head = $cat-&gt;name;
          $cat_id = $cat-&gt;term_id;
      }
      echo "&lt;a href=''&gt;" . $head . "&lt;/a&gt;";
      wp_list_cats("sort_column=NAME&amp;optioncount=0&amp;hierarchical=1&amp;hide_empty=0&amp;child_of={$cat_id}");
  }
  </code></pre>
  
  <p>?></p>