• This is driving me crazy.

    I can’t get .current-cat class to display on the LI of my currently viewed CHILD categories. It only seems to work on the LI of PARENT categories.

    Let me explain…

    I have a custom category archive template, named category-12.php. This is used to display categorized portfolio projects. “Portfolio” is my parent category with an ID of 12.

    I list the portfolio categories using the following:
    <?php wp_list_categories('title_li=&child_of=12'); ?>

    This generates a list which looks like this:

    <li class="cat-item cat-item-13"><a href="https://maryshaw.net/category/portfolio/p-copywriting/">Copywriting</a></li>
    <li class="cat-item cat-item-14"><a href="https://maryshaw.net/category/portfolio/p-ux/">UX</a></li>
    <li class="cat-item cat-item-16"><a href="https://maryshaw.net/category/portfolio/p-wpm/">Web Project Management</a></li>

    Clicking each link correctly filters only those projects assigned to that category. For example, when I click “Copywriting”, the page lists projects that are filed under the categories Portfolio > Copywriting. Good.

    THE PROBLEM:
    Once clicked, the LI tag wrapping the Copywriting link does not add the class “current-cat”.

    Without the “current-cat” class added to the currently viewed category, I’m unable to indicate which portfolio category the user is currently viewing.

    https://maryshaw.net/category/portfolio/

Viewing 1 replies (of 1 total)
  • Once clicked, the LI tag wrapping the Copywriting link does not add the class “current-cat”.

    Yes, it does! Unless you mean that when you click one of Copywriting’s child catgeory links – in which case, look for current-cat-parent.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_list_categories – .current-cat NOT displaying on child categories. HELP!’ is closed to new replies.