afsarwebdev

WP Menu Dynamic

Oct 1st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /***** to dynamic menu take the following step *****/
  2.  
  3. step one:--- to register menu in wp write the following code on functions.php
  4.  
  5. // This code is for register menu
  6.  
  7. function technotiers_theme_menu() {
  8. register_nav_menus(array(
  9. 'main_menu' => 'Main Menu'
  10. ));
  11.  
  12. // this is for top menu
  13. register_nav_menus(array(
  14. 'top_menu' => 'Top Menu'
  15. ));
  16.  
  17. // this is for footer menu
  18. register_nav_menus(array(
  19. 'footer_menu' => 'Footer Menu'
  20. ));
  21.  
  22. }
  23. add_action('init', 'technotiers_theme_menu');
  24.  
  25.  
  26. step two:--- then in menu location write the code between <ul></ul> class
  27.  
  28.  
  29. <?php
  30.  
  31. if (function_exists("wp_nav_menu")){
  32.  
  33. 'theme_location' => 'main_menu',
  34. 'menu_class' => 'write your menu class to get css',
  35. 'menu_id' => 'write your menu id to get css',
  36. ))
  37. ?>
  38.  
  39.  
  40.  
  41. /* CSS for show active menu in WordPress*/
  42. li.current-menu-item a{
  43.  
  44. }
Add Comment
Please, Sign In to add comment