• Resolved formica

    (@formica)


    Hi

    I’m attempting to echo the current child category outside the loop the nearest I’ve found is this:

    <?php
    foreach((get_the_category()) as $childcat) {
    if (cat_is_ancestor_of(4, $childcat)) {
    echo $childcat->cat_name;
    }}
    ?>

    But can anyone let me know how to make this work outside the loop please?

Viewing 1 replies (of 1 total)
  • Thread Starter formica

    (@formica)

    Just found solution using single_cat_title

    <?php if(is_category()) { single_cat_title(); } ?>

    Simple really.

Viewing 1 replies (of 1 total)
  • The topic ‘Get the current child category’ is closed to new replies.