How Do I Add a Top Level Menu in WordPress?

Adding a top level menu in WordPress is simple, and there are a number of different ways to do it. The most common way is to use the wp_nav_menu() function, but there are also a number of other options available.

If you want to use the wp_nav_menu() function, you will need to include the following code in your theme’s functions.php file:

function my_menu() { wp_nav_menu( array(‘menu_name’ => ‘My Menu’, ‘menu_class’ => ”, ‘primary_menu_id’ => ‘main-menu’, ‘container_class’ => ”, ‘depth’ => 1, ‘items_per_page’ => 20, ‘container_id’ => ‘main-menu’, ‘item_parent_id’ => null, ‘item_type’ => ‘navigation’, ‘depth_type’ => ‘navigation’) ); }

To add a top level menu in WordPress, you will first need to create a menu item for the menu you want to create. The menu item should have the following attributes:

menu_name – This is the name of the menu item.

– This is the name of the menu item. menu_class – This is the class name of the menu item.

– This is the class name of the menu item. primary_menu_id – This is the ID of the menu item as it will appear in the WordPress admin area.

– This is the ID of the menu item as it will appear in the WordPress admin area. container_class – This is the class name of the menu item’s container.

– This is the class name of the menu item’s container. depth – This is the number of levels of menus the menu item will appear in.

– This is the number of levels of menus the menu item will appear in. items_per_page – This is the number of items per page in the menu.

– This is the number of items per page in the menu. container_id – This is the ID of the container in which the menu item will appear.

– This is the ID of the container in which the menu item will appear. item_parent_id – This is the ID of the parent item for the menu item.

– This is the ID of the parent item for the menu item. item_type – This is the type of menu item.

– This is the type of menu item. depth_type – This is the type of depth the menu item will have.

After you have created the menu item, you will need to add it to the wp_nav_menu() function call. The following code will add the menu item to the top level menu:

wp_nav_menu( array(‘menu_name’ => ‘My Menu’, ‘menu_class’ => ”, ‘primary_menu_id’ => ‘main-menu’, ‘container_class’ => ”, ‘depth’ => 1, ‘items_per_page’ => 20, ‘container_id’ => ‘main-menu’, ‘item_parent_id’ => null, ‘item_type’ => ‘navigation’, ‘depth_type’ => ‘navigation’, ‘items’ => array( ‘My Menu Item’ => array(), ) ) );

After you have added the menu item to the wp_nav_menu() function call, you will need to add a link to the menu item in the WordPress admin area. The following code will add a link to the menu item in the WordPress admin area:

add_menu_item( ‘My Menu Item’, ‘My Menu’, ‘main-menu’ );

Finally, you will need to add a line to the bottom of the WordPress theme’s footer to disable the default menu:

© 2013 ThemeMysteries.com

© All Rights Reserved

Conclusion

Adding a top level menu in WordPress is simple and there are a number of different options available. The wp_nav_menu() function is the most common way to do it, but there are also a number of other options available.