Home » » how to assign a menu in worpress themes

how to assign a menu in worpress themes

in wordpress code you can add meney menu in specific place by using a function call wp_nav_menu();  The menu assigned to the primary position is the one used.
there are to step :
1.first step you need declare a menu name as you like. example i would like to assign one more and named second_menu.
$nav_menu_arg = array();
$nav_menu_arg['second_menu'] = __( 'Menu description', 'mymenu' );

if($nav_menu_arg){ register_nav_menus( $nav_menu_arg );}

2.final you call menu to display on you specific place:

<?php wp_nav_menu( array( 'theme_location' => 'second_menu', 'menu_class' => 'nav-menu cate' ) ); ?>


$catNav = '';
if (function_exists('wp_nav_menu')) {
$catNav = wp_nav_menu( array( 'theme_location' => 'second_menu', 'menu_class' => 'nav', 'menu_id' => 'cat-nav', 'echo' => false, 'fallback_cb' => '' ) );};
if ($catNav == '') { ?>
<ul id="cat-nav" class="nav">
                               <li class="cat-item cat-item-1">
<a href="<?php echo home_url(); ?>">Home </a>

<?php } else echo($catNav); ?>
Share this acticle :


Post a Comment


Proudly powered by Blogger