Forum Replies Created

Viewing 1 replies (of 1 total)
  • 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>'; }} ?>

Viewing 1 replies (of 1 total)