How to add WordPress navigation menu settings

Source: Internet
Author: User

Navigation menus are not supported in versions earlier than wordpress3.0. Although many topics earlier than wordpress3.0 integrate single navigation menus, some do not have navigation menus. After wodpress was developed to version 3.0, it was able to support navigation menus in the native mode. If you are idle, you can modify your topic to support the original wordpress navigation menu.

If "The current theme dose not natively support menus is displayed under" Appearance/menu "in The wordpress background, but you can use the "Custom Menu" widget to add any menus you create here to the theme's sidebar ", it is prompted that your topic does not support navigation menus.

To use the wordpress navigation menu, you need to do three things:

1. Register the navigation menu in function. php;

Add the following code to the function file function. php in the topic root directory to register the navigation menu:

The code is as follows: Copy code
Register_nav_menus (array ('primary '=> 'primary navigation '));

Here, primary can be modified by itself, as long as it does not repeat with other variables; Primary Navigation is the menu name and can be modified by yourself (preferably an English character ). Http://www.111cn.net

Using the above function, you can add multiple custom navigation menus to wordpress, such:

The code is as follows: Copy code

Register_nav_menus (array ('primary '=> 'primary navigation '));

Register_nav_menus (array ('secondary' => 'secondary navigation '));

Register_nav_menus (array ('bottom' => 'bottom navigation '));

After the preceding three lines of code are added, the following content is displayed in the "appearance/navigation menu" of the wordpress background:

Wordpress navigation menu

2. Call the navigation menu at an appropriate location in the topic file;

Use wp_nav_menu (); function call navigation menu where the topic is suitable. The call method is as follows:

The code is as follows: Copy code

Wp_nav_menu (array ('theme _ location' => 'primary'); // call the first menu

Wp_nav_menu (array ('theme _ location' => 'secondary '); // call the second menu

Wp_nav_menu (array ('theme _ location' => 'bottom '); // call the third menu

Generally, the navigation menu function is called in header file header. php, but some wordpress themes are exceptional and need to be solved according to your own situation. You can also call navigation menus elsewhere, such as at the bottom of a website.

If your wordpress topic uses the wp_nav_menu (); or wp_list_pages (); Method for navigation menus, or uses the self-built function of the topic for navigation menus, you need to replace these functions with wp_nav_menu (); functions. Now we need to combine the wp_nav_menu (); parameters and add the class, id and so on to use CSS to control the style of the new navigation menu. Of course, wp_nav_menu (); there are many parameters in the function, refer to the wordpress navigation menu function wp_nav_menu ();.

If you have no navigation menu before your topic, add wp_nav_menu () in the header. Php file. The function is the proper position? Haha, I can't tell you this clearly. The subject is different, and the header file header. php content is also very different. Maybe the proper position is in a div box in the body tag.

Note: If you only use a category directory or page for navigation, do not use the wp_nav_menu () function to call the navigation menu, because wp_nav_menu (); and wp_list_pages (); are more efficient, wp_nav_menu (); and wp_list_pages (); are more suitable for navigation menus ......

3. Create a navigation menu in the wordpress background.

Now you can use the original navigation menu of wordpress. Log on to the wordpress control panel and go to the "appearance/navigation menu ".

Wordpress allows you to create multiple navigation menus, including category directories, page pages, "homepage" items, and custom links (add other links directly in the navigation menu ). The category directory and the display name of the page in the navigation menu can also be modified.

Now, start to create a menu, give a name to your menu, and enter the menu name in the "menu name" box, then add all the content you want to add to the navigation menu on the left to the right area. To create a level-2 menu and a level-4 directory, you only need to drag the content of the level-2 directory to the back of the level-1 directory in the menu area, and create level-3 and level-4 directories in the same way. Click the plus sign to create another menu. Click "save menu. If no menu is created, the page name is displayed by default after wp_nav_menu () is called.

Note that after saving the created menu, you need to select the menu you just created from the drop-down list in the "topic location" column and save it.

Create a wordpress navigation menu

Note: If you find a pendant named "custom menu" in "appearance/pendant", it is not affected by the subject. If you do not want to create a navigation menu in the website header or do not want to modify the topic, you can drag the pendant to the left sidebar and select the menu group created in step 1 in the pendant options to save the trouble of step 2 and step 3, you don't need to modify the topic, so you can put the navigation menu in the sidebar of the website.

 

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.