wp_list_categories - .current-cat NOT displaying on child categories. HELP! (2 posts)

  1. bcWeb
    Posted 7 years ago #

    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="http://maryshaw.net/category/portfolio/p-copywriting/">Copywriting</a></li>
    <li class="cat-item cat-item-14"><a href="http://maryshaw.net/category/portfolio/p-ux/">UX</a></li>
    <li class="cat-item cat-item-16"><a href="http://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.

    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.


  2. esmi
    Forum Moderator
    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.