Register WordPress menus to a theme

How to register menus for your wordpress th

Today I am going to share the script to register menus for any WordPress theme. Most popular and premium themes have menu setup option and it helps the user to create menus( sometimes theme support multiple menus ) easily from the WordPress back-end.

If the theme does not provide that option then you can add the following lines of  code in functions.php page to register your own menu. This is quite easy to do. Please check the following steps.

Step 01: Go to functions.php page in to theme folder.

Step 02: Open it using any text editor and write following codes in there.

function register_my_menus() {

        'top-menu' => 'Top Menu' ,
        'main-menu' => 'Main Menu'


add_action('init' , 'register_my_menus');

How it work?

In the aforementioned example, we created a new function named “register_my_menus”, and inside that we called a WordPress function “register_nav_menus”. This “register_nav_menus” function takes an array as parameter. In that array, we’ve defined no of menus according to our need. In this example we are going to add 2 menus.

We named those two menus as “top menu” and “main menu“. Generally, top menu set at the starting of page and main menu set just below the logo. But it can be differ from theme to theme.

Please note that, each menu ID needs to be unique to avoid conflict and you can use prefix for that. If you did everything properly, then you will see the newly registered “Menus” in the WordPress menu page.

Register menu demo

I hope that simple snippet helps you to register new menus to your WordPress site.

Was this information useful? What other tips would you like to read about in the future? Share your comments, feedback and experiences with us by commenting below!

Total 0 Votes

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Comment

Back To Top