LIT Blog : Adding WordPress 3 Menus to your WordPress Theme: Part 1

Posted on July 12th, 2010

As WordPress developers and educators, we are often asked questions about configuring and customizing WordPress menus.

In the past, there has never been a standard way to implement a menu in WordPress.   There are solutions ranging from elegant custom written code, to hacks and static hard-coding that is difficult to manage and maintain.

With the recent launch of WordPress 3, a new navigation and menu system has been introduced.   Many of you will want to learn how to implement this powerful new function to your existing WordPress theme, so we have produced a series of screencast tutorials.

There are generally 4 steps required to do this:

  1. Add menu capabilities to your theme
  2. Define/create your menu using the WordPress administration
  3. Modify your page template(s) to display the menu
  4. Style the menu

We have developed a video tutorial to walk you through the basics of each of these steps.

Introduction

Part 1: Enabling menus in your WordPress Theme

In Part 1, we modify our theme functions file (functions.php) to enable one custom menu:

Here is the code to add to functions.php:


add_action( ‘init’, ‘register_menu’ );
function register_menu() {
register_nav_menus(
array(
‘menu-1′ => __( ‘Main Menu’ )
)
);
}

In Part 2, we will look at how to configure the menu in the WordPress admin.  Stay tuned!

Update: Part 2 has been added.  Check it out!

Leave a Reply