3

I used wp menus in the past but always registering a location and then using:

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

To display a menu on that location on my theme I would first create a menu, and then assign it to that location.

Well now what I would like to do is to create all the menus I want using some standard name like my-menu-1, my-menu-2, my-menu-x. And then I want to display those menus on my theme but without using any location, just printing them using code identifying them by name.

How could I do that?

1

1 Answer 1

1

Umm u can do that easily. And this is the way I do

how i register my menu in functions.php

add_action('init', 'register_custom_menu'); 
function register_custom_menu() {
    register_nav_menu('custom_menu', __('Custom Menu'));
}

Then in ur admin panel u create different menu by ur desired name. And get the menu where ever u want like this. EX:- if I made two menu in admin by name "Menu 1" and "Menu 2"

wp_nav_menu(array('menu' => 'Menu 1'));
wp_nav_menu(array('menu' => 'Menu 2'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.