Advertisement
firoze

Wordpress Menu Usages

Dec 11th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.93 KB | None | 0 0
  1. <!-------------------------------------------------------------------------------------------------------------------------->
  2. //This code have to use in functions.php to registered menu
  3. /******This code for registration for wp menu**********/
  4.     function wpj_register_menu() {
  5.          if (function_exists('register_nav_menu')) {
  6.             register_nav_menu( 'top_main_menu', __( 'Main Menu', 'brightpage' ) ); // Here (wpj-main-menu) is unique id &  Main Menu is display name
  7.            
  8.             // Registared Another Menu
  9.         }
  10.     }
  11. add_action('init', 'wpj_register_menu');
  12. <!---------------------------------------------------------------------------------------------------------------------------->
  13.  
  14. <!------------------------------------------------------------------------------------------------------------------------->
  15.  //This code have to use instead of ul li
  16.               <?php
  17.                 if (function_exists('wp_nav_menu')) {
  18.                  wp_nav_menu(array(
  19.                  'theme_location'  => 'top_main_menu', // this id from functions.php
  20.                 'menu'            => '',
  21.                 'container'       => 'div',
  22.                 'container_class' => '', // this class is of before <ul> that is class of div
  23.                 'container_id'    => '', // this id is of before <ul> that is id of div
  24.                 'menu_class'      => 'menu', // this class is of <ul></ul>
  25.                 'menu_id'         => '',  // this id is of <ul></ul>
  26.                 'echo'            => true,
  27.                 'fallback_cb'     => 'wp_page_menu',
  28.                 'before'          => '',
  29.                 'after'           => '',
  30.                 'link_before'     => '',
  31.                 'link_after'      => '',
  32.                 'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',       
  33.                 'depth'           => 0,
  34.                 'walker'          => ''
  35.                  
  36.                  
  37.                  ));
  38.                 }
  39.                 else {
  40.                  wpj_default_menu();
  41.                 }
  42.                 ?>
  43. <!------------------------------------------------------------------------------------------------------------------------->
  44.  
  45.  
  46. This is wordpress source link:https://codex.wordpress.org/Function_Reference/wp_nav_menu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement