List all Subcategories

Adding this PHP code to your wordpress theme will display a list of only subcategories

 

 

 

$echo = '<ul>' . "n";
$childcats = get_categories('child_of=' . $cat . '&hide_empty=1');
foreach ($childcats as $childcat) {
if (1 == $childcat->category_parent) {
$echo .= "t" . '<li><a href="' . get_category_link($childcat->cat_ID).'" title="' . $childcat->category_description . '">';
$echo .= $childcat->cat_name . '</a>';
$echo .= '</li>' . "n";
}
}
$echo .= '</ul>' . "n";
echo $echo;

Be Sociable, Share!

Leave a comment