My code for loop of categories
<?php
$categories = get_categories('hide_empty=1&exclude=1&orderby=slug&order=ASC');
foreach ($categories as $category) {
echo '<li class="cat-item cat-item-'.$category->cat_ID.'">';
echo '<a href="'.site_url().'/category/'.$category->slug.'">';
echo $category->cat_name;
echo "</a>";
echo ' ('.$category->category_count.')';
echo '</li>';
}
?>
Preview the code above:
<ul>
<li><a href="#">Category one</a></li>
<li><a href="#">Category two</a></li>
<li><a href="#">CHILDREN OF Category third</a></li>
<li><a href="#">Category third</a></li>
</ul>
I would like to stay:
<ul>
<li><a href="#">Category one</a><span class="description">...</span>
<ul class="children">
<li><a href="#">Children primary of Category one</a></li>
<li><a href="#">Children second of Category one</a></li>
<li><a href="#">Children third of Category one</a></li>
</ul>
</li>
<li><a href="#">Category two</a><span class="description">...</span></li>
<li><a href="#">Category third</a><span class="description">...</span>
<ul class="children">
<li><a href="#">Children primary of Category third</a></li>
<li><a href="#">Children second of Category third</a></li>
<li><a href="#">Children third of Category third</a></li>
</ul>
</li>
</ul>
understand?