• I have a question. I have a menu with the referd php tag wp_list_categorys. And I want the menu links to shown as active. I′ve used the class .current_cat to display active links in the menu. But if I am in a article with a child category, it wont show the main category as active. Anyone know how to make the main category for the child categories to be in a active state when the child category is in a article?

    //Vincent

Viewing 7 replies - 1 through 7 (of 7 total)
  • Try styling on .current-cat-parent

    Thread Starter vincentklaiber

    (@vincentklaiber)

    Thx esmi! it work if you selected one of the child categorys. =)
    But if i select a article i wont show in the .current state? Can I fix this?

    I haven’t come across a workaround for this yet. Sorry ??

    Thread Starter vincentklaiber

    (@vincentklaiber)

    Thx anyway! But I am just saying that if I am reading a article that is in the category “example”. Then I want just that category to display in a active “class” state.
    Know how to fix this?

    The only solution I’ve found is by using inline styles.

    You can dynnamically write out a block of style code to match the “cat-item-1”, “cat-item-2”, “cat-item-3” classes that WordPress creates.

    <style>
    <?php
    foreach((get_the_category()) as $category) {
        echo '.cat-item-'.$category->cat_ID . '{border:1px solid red} ';
    } ?>
    </style>

    It only works visually if you’re using a strict category system where each post is a member of a single category at each category heirarchy level. Otherwise it displays like you’re ‘active’ at several places.

    Thread Starter vincentklaiber

    (@vincentklaiber)

    Did not get it to work.. But i have seen these over at https://www.tutorial9.net, that they have lighten up=(‘active’) the main category even if you are in a child category-post.

    Well I imagine that they are using category templates to show the top level nav as active.

    i.e. they’re aren’t using wp_list_categorys to generate the toplevel nav only the 2nd.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Active menu(category)links with classes?’ is closed to new replies.