Skip to main content

WordPress – How To Register Menu And Show in Theme

Submitted by admin on Thu, 12/09/2021 - 09:23
In this WordPress tutorial, I will explain how to:

  • Register menu
  • Display menu in your theme.

Register menu

Let's say, we want to register / create two menus. One for header and another for footer.
Copy paste below code in functions.php file of your theme.

* Register menus
function register_my_menus() {
		 'header-menu' => __( 'Header Menu' ),
		 'footer-menu' => __( 'Footer Menu' )
add_action( 'init', 'register_my_menus' );

Above code will register following two menus.
1) Header Menu
2) Footer Menu


Show menu in theme

To show header-menu in your WordPress theme, add following codes in template file where you wish to show menu like in header.php

<nav class="header-menu">
	<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>

Similarly, to show footer-menu, use below code.

<nav class="footer-menu">
	<?php wp_nav_menu( array( 'theme_location' => 'footer-menu' ) ); ?>

Hope this article was helpful to you.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.