How to add menu to WordPress Theme

The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.

Some WordPress themes doesn’t natively support Menus which has been added in WordPress 3.

to solve this problem you have to add this code to your Theme functions.php file first

 

add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'header' => __( 'Header Menu' ),
'footer' => __( 'Footer Menu' )
)
);
}

the next step is to call the menu ,

place this code in your header.php file where you want the menu to appear

<?php wp_nav_menu( array( 'theme_location' => 'header' ) ); ?>

and the same goes for the footer menu, place this code in your footer.php file where you want the menu to appear

<?php wp_nav_menu( array( 'theme_location' => 'footer' ) ); ?>

after completing the steps, your theme will support WordPress Menus

Tags: ,
fold-left fold-right
About the author

I’m d3mha, and i <3 WordPress

12 Replies to How to add menu to WordPress Theme

  1. Sunny says:

    After adding the footer menu, how do you horrizontally centre the footer menu

    • d3mha says:

      you can try display: inline;
      you can use padding and margin to adjust the position 🙂 im not a CSS guru but i hope this would help

    • Romer Ejida says:

      Try to edit the css. (I’m using ” footer-nav” in menu )
      .menu-footer-nav-container{ text-align:center;}
      ul#menu-footer-nav{ display:inline-block;}
      ul#menu-footer-nav li{ float:left;}

  2. xing says:

    Very helpful.. thank you!

  3. You are missing a ‘ on line 6:

    ‘footer’ => __( ‘Footer Menu )

    should read:

    ‘footer’ => __( ‘Footer Menu’ )

  4. Owen says:

    How to add horizontally in Header menu?

    I received the menu in one by one, not horizontally.

Leave a Reply