Topic: List category children

Hello,

I need to list the children of one of my categories. Right now I am using this:

<?php
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(153, $childcat)) {
echo '<a href="'.get_category_link($childcat->cat_ID).'">';
 echo $childcat->cat_name . '</a>';}}
?>

But as you can see here: http://oriolesprospects.com/transactions/

There are no commas in between "Aberdeen IronBirdsNorfolk Tides". It should read" "Aberdeen IronBirds, Norfolk Tides"

How do I add commas in between?

I guess I could also use:

<?php the_category(', '); ?>

But then I'd need a way to make sure it excludes the parent category and lists just the children. All help appreciated. Thanks!

Re: List category children

Got this one myself:

<?php
//edit below for categories you want excluded
$exclude = array("Transactions");
//how do you want the list separated? just a space is okay
$separator = " | ";
//don't edit below here!
$new_the_category = '';
foreach((get_the_category()) as $category) {
if (!in_array($category->cat_name, $exclude)) {
$new_the_category .= '<a href="'.get_bloginfo(url).'/transactions'.get_option('category_base').'/'.$category->slug.'/">'.$category->name.'</a>'.$separator;
}
}
echo substr($new_the_category, 0, strrpos($new_the_category, $separator));
?>