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 :

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') ); ?>

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.

Share This Post


Add a Comment
  1. Thanks! Very simple and very easy. Just what I was looking for.

Leave a Reply to Ronnie Albert Cancel reply

Please write your comments in english. I delete anything that even remotely resembles spam.

Note: When posting code, enclose it in pre and code tags.
e.g. Add code here