Highlight "Blog" menu when accessing a category or post

Asked

Viewed 53 times

0

I have a wordpress site and would like as it is selected the menu according to the page I am, also be selected the item "Blog" menu when I am on a category page or in a post.

This is the menu code of my theme:

$defaults = array(
    'container'         => 'nav',
    'theme_location'    => 'primary',
    'depth'             => 3,
    'walker'            => new ts_walker_nav_menu
    );
wp_nav_menu( $defaults ); ?>

1 answer

0

By default wordpress puts the class ". Current-menu-item" in the item that is selected in the menu, try styling that class in your css.

But if I understand the question correctly, you need the "blog" menu also to be highlighted, you will need a test, because the Nav function will not automatically identify that the blog is active, as it will return the category item as active.

  • So, would you know where to find this Nav function that assigns the Current-menu-item class in the active item? Then I could try to fit the condition to also highlight the "blog" when in some category or post.

  • it puts the class by default

Browser other questions tagged

You are not signed in. Login or sign up in order to post.