Wordpress custom menu wp_nav_menu code details

Source: Internet
Author: User
The wp_nav_menu () method is located in the wp-nodes des/nav-menu-templates.php file. This method is used to generate menus in the background. Before using this function, you must activate the theme 3.0 + menu function. The activation method is as follows: add if (function_ex

The wp_nav_menu () method is located in the wp-nodes des/nav-menu-templates.php file.

This method is used to generate menus in the background.

Before using this function, you must activate the theme 3.0 + menu function.

The activation method is as follows:

Add the following content to the functions. php file:

If (function_exists ('register _ nav_menus ') {register_nav_menus (array ('header-menu' => _ ('Navigation custom menu '), & apos; footer-menu & apos; = & apos; _ ('custom menu of page'), & apos; sider-menu & apos; = & apos; _ ('sidebar menu ')));}

A simple call is as follows:

 ''// Specifies the displayed navigation name. if not set, the first 'menu '??????????? => 'Header-menu ', 'container '?????? => 'Nav', // The container label name of the outermost layer is 'iner INER _ class' => 'primary', // The container class name of the outermost layer is 'iner INER _ id '??? => '', // The Container id value of the outermost layer is 'menu _ class '????? => 'SF-menu ', // ul Label class 'menu _ id '???????? => 'Topnav', // ul tag id 'echo '??????????? => True, // whether to print. the default value is true. if you want to use the navigation code as a value assignment, you can set it to false 'Fallback _ cb '???? => 'WP _ page_menu ', // The alternate navigation menu function. it is used to call 'before '????????? => '', // Display 'after '?????????? => '', // Display 'link _ before' after the tag in the navigation bar '???? => '', // Display 'link _ after' after the navigation link name '????? => '', // It is displayed before the navigation link name 'items _ wrap '????? =>'
 
 
    % 3 $ s
', 'Dest '?????????? => 0, /// number of menu layers displayed. the default value 0 is to display all layers 'Walker '????????? => ''// Call an object definition display navigation menu);?>

This menu bar is generated based on whether or not to log on.

  'logged-in-menu' ) );} else {     wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) );}?>

Remove menu bar

 

Or

  '' ) );??>

The generated menu css style is

Note: The category menu data called by the wp_nav_menu function comes from the "Appearance> menu" in the background. if you do not want to display a category menu, you only need to remove it from the background!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.