I am creating a theme for my wordpress blog, I am struct on the code to display custom menus
in my functions.php I have wrote:
function register_my_menus(){
register_nav_menus(
array('menu-1' => __('Primary Menu'),
)
);
}
add_action('init', 'register_my_menus');
this is my header.php
if ( has_nav_menu( $location ) ) {
wp_nav_menu(array( 'theme_location' => 'menu-1'));
}
the problem is that when I am setting a menu from wordpress to Primary Menu, no menu is displaying and also the content after menu is not displaying, please help me where I am wrong
You’ve used the has_nav_menu() command, by the looks of it, copy/pasted from the Codex, without giving it a parameter. Try this:
Instead of
This:
Then, provided you’ve actually made a menu for the location in the admin panel, and assigned it to this location, it should work as far as I can see.
Hi mandeep singh did you assign your menu to the Primary Menu in the wordpress admin pannel