Search code examples
wordpresswordpress-themingmegamenu

How to make Jet - Responsive Megamenu compatible with Wordpress?


Is Jet - Responsive Megamenu compatible with Wordpress? If not how can i make it work with Wordpress menu system?


Solution

  • Below you have the code that makes the menu to work on Wordpress. It is tested on Wordpress 4.3 but I think it works on Wordpress 3.2+ (I'm not 100% sure).

    <?php
    /* Put this script inside header.php in Wordpress theme folder */
    
    class My_Walker_Nav_Menu extends Walker_Nav_Menu {
            function start_lvl( &$output, $depth = 0, $args = array()) {
            $indent = str_repeat("\t", $depth);
                    $output .= "\n$indent<ul class=\"dropdown\">\n";
            }
    }
    
    $menuSettings = array(
            'container'       => 'div',
            'menu_class'      => 'jetmenu yellow', //change this to whatever classes you need for your menu
            'echo'            => true,
            'fallback_cb'     => 'wp_page_menu',
            'items_wrap'      => '<ul id="%1$s" class="%2$s dropdown">%3$s</ul>',
            'depth'           => 3, //the number of submenus + 1
            'walker'          => new My_Walker_Nav_Menu()
    );
    
    wp_nav_menu( $menuSettings ); //This script displays the menu. Please put it where you want it to display the menu.
    
    ?>
    

    I hope this solves someone's problem.