WordPress custom menu

How to create WordPress custom menu

Step 1. register_nav_menu()

In functions.php add the following code

function register_my_menu() {
    register_nav_menu('my-new-menu',__( 'My New Menu' ));

add_action( 'init', 'register_my_menu' );

I after adding this code the new menu will started showing in admin (Appearance->menu)

wordpress custome menu admin

We can register multiple menus at same time

                'mnu-1' => 'Menu One',
                'mnu-2' => 'Menu Two',

Step 2. wp_nav_menu()

Call ‘ wp_nav_menu()’ wherever you want to display the newly created menu

I am just adding in footer.php

<div id="footer-2">
    <?php wp_nav_menu( array( 'theme_location' => 'my-new-menu' ) ); ?>


new menu in footer


ref: https://codex.wordpress.org/Function_Reference/register_nav_menu

ref : https://codex.wordpress.org/Function_Reference/register_nav_menus

Author: bm on June 22, 2016
Category: wordpress
Tags: ,

Your comment:

Your Name


Last articles