I need to display the subcategories of of a category on my new website.
My structure is as following:
Test1
- Sub1_1
- Sub1_2
Test2
- Sub2_1
- Sub2_2
When I am on the category page of "Test1" I need to display the sub categories ("Sub1_1" and "Sub1_2"). I found the following snippet on the web which does display the sub cat:
if (is_category()) {
$this_category = get_category($cat);
}
?>
<?php
if($this_category->category_parent)
$this_category = wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent."&echo=0");
else
$this_category = wp_list_categories('orderby=id&depth=1&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0");
if ($this_category) { ?>
<ul>
<?php echo $this_category; ?>
</ul>
<?php } ?>
But it does this in an unordered list with <ul> and <li>.
<ul>
<li>Sub1_1</li>
<li>Sub1_2</li>
</ul>
Instead of this list I need to display a div with the sub category title and the corresponding sub cat description (or even better: an excerpt of the description, but for the moment I would be happy to just get the full description). The layout has to be something like
<div class="cat-list">
<div class="cat-subcat">
<h2 class="cat-title">Sub1_1</h2>
<p class="cat-text">Subcat1_1 description</p>
</div>
<div class="cat-subcat">
<h2 class="cat-title">Sub1_2</h2>
<p class="cat-text">Subcat1_2 description</p>
</div>
</div>
How can I adjust the snippet, that it can be displayed in the way I want to show it?