• Hi,

    I have my menus all ready to go and looking good, but was wondering how would I modify CSS to force all second level menus to remain open (mega menu style) only when the parent page or its child page is selected?

    For example:

    Parent page 1 (top menu)
    Child page 1 | Child page 2 | Child page 3 | Child page 4 (submenus)

    When Parent page 1 or child page 1 or child page 2 or child page 3 or child page 4 is open, force these second level menus to stay open.

    I hope I had made myself clear! 🙂

    Please see my staging site: http://goo.gl/PxTsnn

    Thanks!!!

    Paula

    https://wordpress.org/plugins/megamenu/

Viewing 1 replies (of 1 total)
  • Plugin Author megamenu

    (@megamenu)

    Hi Paula,

    You can try adding this to your themes functions.php file, but note it is only going to work if your menu and pages are set up in a very specific way (e.g. you can’t put a link to the same page in 2 sub menus).

    function megamenu_keep_active_submenu_open( $classes, $item, $args ) {
        if ( ( in_array( 'mega-current_page_ancestor', $classes ) || ( in_array( 'mega-current_page_item', $classes ) || in_array( 'mega-current-menu-ancestor', $classes ) ) && in_array( 'mega-menu-item-has-children', $classes ) ) ) {
            $classes[] = 'mega-toggle-on';
        }
    
        return $classes;
    }
    add_filter( 'megamenu_nav_menu_css_class', 'megamenu_keep_active_submenu_open', 10, 3 );

    I only usually provide free support for bugs and helping users use existing features, and I wouldn’t recommend for everyone to do what you’re trying to do. For those reasons I can’t commit to supporting this code any further, but it should at least get you started.

    Regards,
    Tom

Viewing 1 replies (of 1 total)
  • The topic ‘Force Second Level Mega Menus to Stay Open’ is closed to new replies.