WordPress.org

Support

Support » Themes and Templates » Tempera » Highlight current page/menu-item in menu?

Highlight current page/menu-item in menu?

  • Is there support for the above:
    – in theme setting admin pages?
    – in CSS?

    Can this be added via functions.php?

    Thanks
    Mulli

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve gone through the code of your theme as it is in the WP repository, and it looks like you have the option of adding custom styles, including the menu items and current menu item’s styles. I haven’t installed the theme, therefore I don’t know what this looks like in practice, but it shouldn’t be hard to find in the admin panel.

    I can’t say how to achieve this via CSS because I don’t have a link to your site, therefore I’ve got no way of pinpointing the right selectors to achieve the desired results.

    Hi.
    I found a solution:
    1. Add the following to functions.php (child theme)

    add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
    function special_nav_class($classes, $item){
         if( in_array('current-menu-item', $classes) ){
                 $classes[] = 'active ';
         }
         return $classes;
    }

    2. Now you have the ‘active’ class that you can manipulate via CSS.

    Thanks
    Mulli

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Highlight current page/menu-item in menu?’ is closed to new replies.
Skip to toolbar