Skip to content
WordPress Garden
Growing in the knowledge of Web Design and Development
  • Home
  • About

Using Custom Menus in WordPress 3.0

by Hayley7 on August 23rd, 2010

Menu LinkWordPress version 3.0 includes an exciting new feature: Custom Navigation Menus. This menu system allows users to build and alter menus with a drag and drop menu interface. Previously menus had to be created in code with wp_list_pages or wp_list_categories, adding extra code to specify which items to include and in what order. Custom menus help users manage menus much more easily. However, to use this easy, code-free menu interface actually requires some coding work to enable it in your existing theme.

Features of the menu system:

  • Drag and drop interface
  • Combines pages, categories, and links
  • Easily re-ordered menu
  • Sub menus
  • Hide specific pages or categories

Here’s a snapshot of the menus panel:
Menu Screen

Follow the steps below to make custom menus a part of your theme!

1. Register menus in your function.php file

Add this code at the bottom of your functions.php file, right before the ending ?>

if ( function_exists( 'register_nav_menus' ) ) {
  	register_nav_menus(
  		array(
  		  'primary_menu' => 'Primary Menu',
  		)
  	);
}

To add multiple menus, follow this pattern:

if ( function_exists( 'register_nav_menus' ) ) {
  	register_nav_menus(
  		array(
  		   'primary_menu' => 'Primary Menu',
  		   'sidebar_menu' => 'Sidebar Menu',
		   'footer_menu' => 'Footer Menu'
		)
  	);
}

2. Create a menu in the menu panel

Now the menus panel will appear under the Appearances tab on the WordPress dashboard.
Build and save a custom menu, giving it a name and including all the pages, categories, and posts you want in the menu.
To create a sub-menu item, drag and drop the item a little to the right of the previous item.
Once you have a menu saved, save it to a location under “Theme Locations”. These locations correspond with the menus you registered in functions.php

3. Insert the menu into your theme

Add this code to your theme file where you want the menu to appear:

<?php wp_nav_menu( array('menu' => 'Primary Menu' )); ?>

Replace “Primary Menu” with whatever you named the menu in the menus panel.

4. Enjoy your easy to manage menu system

Navigation changes will be a breeze from now on!

From → WordPress Features

No comments yet
Click here to cancel reply.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

  • Recent Articles

    • test
    • Steps to a Secure WordPress Installation
    • 5 Resources for Learning WordPress and Web Development
    • Tabber Widget Plugin
    • Using Custom Menus in WordPress 3.0
    • Exploring the Sticky Footer
  • Categories

    • CSS
    • Plugins
    • Resources
    • Uncategorized
    • WordPress Features
  • Archives

    • January 2011
    • October 2010
    • September 2010
    • August 2010

About

Hi! I'm a girl absolutely fascinated with all things WordPress. Join me in the never-ending journey to learn more about creating beautiful and useful websites.

  • Categories

    • CSS
    • Plugins
    • Resources
    • Uncategorized
    • WordPress Features

Search

Copyright © 2012 Wordpress Garden. Titan Theme customized by Hayley Williamson.