WordPress.org

Ready to get started?Download WordPress

Forums

Tempera
Highlight current page/menu-item in menu? (3 posts)

  1. mulli.bahr
    Member
    Posted 4 months ago #

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

    Can this be added via functions.php?

    Thanks
    Mulli

  2. Maria Antonietta Perna
    Member
    Posted 4 months ago #

    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.

  3. mulli.bahr
    Member
    Posted 4 months ago #

    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

Reply

You must log in to post.

About this Theme

About this Topic