WordPress Theme Creation Tutorial 2: navigation menu making

Source: Internet
Author: User

To implement a custom menu, the function that needs to be used is wp_nav_menu ();

In the theme directory of the functions.php <?php ..... ?>, add the following menu registration code so you can use the Wp_nav_menu function in the theme file:

Register_nav_menus ();

Then the menu: "Menu" appears under appearance

To create a menu:

Click "Create New Menu", select the column you want to display, then "save Menu"

Invoke Menu:

Add the following statement to output the menu:

<?php Wp_nav_menu ();?>

The HTML for the output is:

<Divclass= "Menu-nav-container">    <ulclass= "Menu"ID= "Menu-nav">        <Liclass="..."ID= "Menu-item-1"><ahref="...">Xx</a></Li>        <Liclass="..."ID= "Menu-item-2"><ahref="...">Xxx</a></Li>        ...    </ul></Div>

This method also provides a number of parameters, such as:

<?php  wp_nav_menu (array(' menu ' = ' nav ', ' depth ' = ' 1, ' menu_class ' = ' navcontainer '));? >

Gets the menu name of NAV, listing only one level menu, style named Navcontainer

Common parameters:

Menu Desired menu to display
container_id UL parent Node ID value
Container_class UL parent Node class value
Menu_class UL Node class value
menu_id UL Node ID value
Before Text before the menu link
After Text after a menu link
Link_before Text in front of each menu link text
Link_after Text after each menu link text
Depth Menu Depth

WordPress Theme Creation Tutorial 2: navigation menu making

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.