Friday, June 26, 2015

Register Menu in WordPress function and Put it anywhere you like


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. 



1 comments :

 

Copyright @ 2014 Tech Tutorial .