WordPress 3.0 introduced a new menu feature. If you’ve downloaded your theme from WordPress Extend, it might not support the new menus yet, but here I’ll show you how to modify your theme to enable this feature.
Table of Contents
Creating a Menu:
To get started with your custom menu, go to Menus under Appearance. Your first menu will be created for
you when you load this page. If your theme does not support this feature you will get this message
“The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.”
Use the checkboxes on the right side of the page to add new items to your menu. You can add almost any kind of content as a menu item. By default, the menu management page shows pages, categories, and custom links to URLs you specify. However, you can turn on the boxes that will let you add posts, tags, custom content types, and custom taxonomies. You can add multiple items quickly by checking them all at once and pressing the Add to Menu button.
Be sure to press the blue Save Changes or Create Menu button before leaving this screen! Otherwise your menu changes will be lost.
Navigation menus are a big new feature in version 3.0. If you want to support them in your new theme, or if you’re modifying an older theme for 3.0, you’ll need to add the following code to your theme files.
Enabling navigation menus
// in functions.php:
// wherever your current menu tag is located, replace it with:
<?php wp_nav_menu( ‘sort_column=menu_order’ ); ?>
If you prefer, you can use the new Navigation Menu widget rather than placing the menu tag in your templates.
Creating Multiple Menus:
You can create more than one menu. Click the tab containing a plus sign, and you’ll see the menu creation screen. The second menu will become active, and you can begin adding items to it. You can switch back to the first menu using the tab above the drag-and-drop menu item area.
Editing Menu Items:
To edit an item’s details or delete it from the menu, use the arrow on the far right side of the item to show the detail editing box. By default, the menu item will display the title of the page or the name of the category. However, you can change both the label (the linked text) and the title attribute (the tooltip shown on hover). The original title will always be shown at the bottom of the menu item detail box, so you won’t lose track of the item’s source.
In the screen options, you can turn on some additional attributes for each menu item: the link target (whether the link opens a new browser window), CSS classes, link relationships (the same sort of XFN data you saw in the link manager in Chapter 4), and a description (which could be displayed below the link if your theme supports it).
You can create multi-level menus, To create a child menu item, simply drag it a little to the right. You’ll see its underlying drop zone, drawn in a dashed line, shift over to the right in preset intervals as you move the item.
This is the most powerful way to customize existing WordPress themes while keeping the original code intact.