Create a Custom Menu for a WordPress Theme

This post is all about how to create a custom WordPress menu that you can incorporate in your WP Theme.

Register the Menu

The First step is to register the menu so that the potential user may see this:

how to create a wordpress menu

Add this to your WordPress Function.php :

if ( function_exists( 'register_nav_menu' ) ) register_nav_menu( 'menu-primary', 'Primary' );

Output the Menu

Next step is to add the code to display the menu in your theme. This is usually added in the header.php

<nav id="main-menu">
    <?php wp_nav_menu( array('theme_location' => 'menu-primary') ); ?>
</nav>

The only headache-inducing part of creating the navigation is the Styling part. You’ll have to make sure each menu item displays correctly along with dropdown submenus.