Advertisement
wdtobibur

Wordpress Menu

Sep 24th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. WP Menu Simple Code
  2. Past This Code functions.php File.....
  3. this is code for one menu
  4. register_nav_menu('id name','Show Name');
  5.  
  6. register_nav_menus(array(
  7.     'mainmenu' => __('Main Menu','basic'),
  8.     'footermenu' => __('Footer Menu','basic')
  9. ));
  10.  
  11. this is code past menu location...
  12.                 wp_nav_menu(array(
  13.                     'theme_location' => 'mainmenu',
  14.                 ));
  15.  
  16.  
  17. advance Menu System.....
  18. This Is Code Past functions.php
  19.     function theme_menu(){
  20.         if(function_exists('register_nav_menu')){
  21.             register_nav_menu('mainmenu','Andia Menu');
  22.         };
  23.     };
  24.     add_action('init','theme_menu');
  25.    
  26.    
  27.    
  28.     // fall back function
  29.     function menu_fallback_cb(){
  30.         echo '<ul class="nav navbar-nav navbar-right">';
  31.             if(is_user_logged_in()){
  32.                 echo '<li class="active"><a class="page-scroll" href="'.home_url().'/wp-admin/nav-menus.php">Create Menu</a></li>';
  33.             }
  34.             else{
  35.                 echo'<li class="active"><a class="page-scroll" href="'.home_url().'">Home</a></li>';
  36.             }
  37.         echo '</ul>';
  38.     }
  39. #### This is code past Menu Location.....
  40.     if(function_exists('wp_nav_menu')){
  41.         wp_nav_menu(array(
  42.         'theme_location'=>'mainmenu',
  43.         'menu_class' => 'nav navbar-nav',
  44.         'fallback_cb' => 'fallback_menu',
  45.         ));
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement