• Resolved vaughanprint

    (@vaughanprint)


    Hi,

    I am using your plugin to place a menu on a page. I have it styled the way I want it but the one thing that I am not able to solve is showing the active link on the page currently loaded.

    I have tried setting the .current-menu-item > a rule but this has no effect. From what I can see (by inspecting the page in Chrome and looking at the main menu for the theme I am using) this only works where the menu item related to the currently loaded page has the current-menu-item class added to the <li>tag, probably with some php function and/or javascript.

    Anybody know how to implement this with this plugin?

Viewing 1 replies (of 1 total)
  • Thread Starter vaughanprint

    (@vaughanprint)

    Just figured this out, for anyone else may encounter the same issue.

    You can add the following to the functions file of your child theme:

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

    In my case I created a class called: ‘highlight-active-page’ as seen above. So make sure to name and add accordingly for your needs.

    My solution did not straight away work due to the vagaries of my WordPress configuration with Pagelines Platform 5 so you may need to do some extra leg work, like I did to get it working.

Viewing 1 replies (of 1 total)

The topic ‘Highlight current active page’ is closed to new replies.