List child categories of parent category
-
Hi at all,
i have this code:
<?php
$parentCatName = ‘products’;
$parentCatID = get_cat_ID($parentCatName);
$childCats = get_categories( ‘child_of=’.$parentCatID );if(is_array($childCats)):
foreach($childCats as $child){ ?>
<h2><?php echo $child->name; ?></h2>
<?php
}endif;
?>
I created a parent category and some children categories.
I would like to display the name of every child category… but i don’t understand why it not working. The if statement give me TRUE when check if (is_array($childCats))… Someone can explain me where possible is the problem?
- The topic ‘List child categories of parent category’ is closed to new replies.