Register Menu in WordPress function and Put it anywhere you like

Mahabubur Rahman
5
In this topics we will discus on WordPress Menu.

  • How to Register menu
  • How it put any where you like
First of all we register menu for my WordPress template. For this write  menu register code on function.php file  you have already in your template folder. It's like as 


register_nav_menus(array(
'primery'=>__('Main Menu'),
'footer'=>__('Footer Menu')
));

Here I register two menu named Main Menu and Footer Menu. Remember that we will call menu by array key (primery, footer).

Now open your header.php file and write the following code any where you like(For Main Menu)
<?php wp_nav_menu('theme_location=primery'); ?> 
or
<?php
$args=array('theme_location'=>'primery');
wp_nav_menu($args);
?> 
 And then open your footer.php file and write the following code any where you like(For Footer Menu)

<?php
$args=array('theme_location'=>'footer');
wp_nav_menu($args);
?> 
Now go wp-admin->Appearance->Menus
Create Menu from here and select where you want to put this menu from bottom check box.Then Save Menu.
 Now can manage menu from Manage Locations tab. Here you can see the menu areas and menu you already create. Select menu from droop down menu.

 After choosing all menus save the changes.

 Now go your site and see what happened.

Thanks for reading this topics. For any question on this topics please write your question/comment/advice on comment box bellow. 



Post a Comment

5Comments
  1. your guidence is appreciated.I save more time by avoiding errors and work smoothly, this is because of you.WordPress Errors.Keep sharing.Thanks a lot.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
Post a Comment