How Do I Create a Vertical Mega Menu in WordPress?
Creating a vertical mega menu in WordPress is a fairly straightforward process. First, create a new menu item in your WordPress menu system. Next, add a new row to your menu item’s edit screen, and add the following HTML:
Next, add the following CSS to your stylesheet:
ul.menu-item { list-style-type: none; margin: 0; padding: 0; } ul.
menu-item li { display: inline; } ul.menu-item li a { display: block; text-decoration: none; }.
Finally, add the following JavaScript to your theme’s functions.php file:
add_action(‘admin_menu’, ‘vertical_mega_menu’); function vertical_mega_menu() { $items = array( ‘Home’ => ‘http://www.example.com/’, ‘About’ => ‘http://www.com/about-us/’, ‘Services’ => ‘http://www.
com/services/’, ‘Blog’ => ‘http://www.com/blog/’, ‘Contact’ => ‘http://www.com/contact-us/’); $items[‘vertical_mega_menu_item’] = array( ‘title’ => __( ‘Vertical Mega Menu’, ‘example’ ), ‘href’ => $items[‘services’], ‘data-Target’ => ‘#vertical_mega_menu_item_services’, ‘class’ => ‘menu-item’); }.
In this code, the vertical_mega_menu_item variable is an array that contains the following items: Home, About, Services, Blog, and Contact. The title of the menu item is “Vertical Mega Menu,” and the href attribute links to the respective menu items.
The data-Target attribute points to the #vertical_mega_menu_item_services ID in the menu item’s edit screen. Finally, the class attribute sets the menu item’s style to be a list item.