Question:
I am trying to do something very similar, except it isn’t working. I want the code to display the child category of a given parent category even if the parent category is not selected. The parent category is named Material.
<?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of('Material', $childcat)) { echo '<a href="'.get_category_link($childcat->cat_ID).'">'; echo $childcat->cat_name . '</a>'; }} ?>