WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've read a few tutorials on how to add the functionality of the custom menus added in version 3.0 to my theme but they all seem to differ somewhat, and I'm not sure whether they contain superfluous code. In addition I read that the code to register your theme as menu-compatible changed between the RC and the public release.

What's the simplest way of adding support for custom menus to my theme?

share|improve this question
up vote 7 down vote accepted

The easiest way is to use the register_nav_menus function.This should be hooked into 'after_setup_theme':

function my_cool_menu_function(){
  register_nav_menus( array(
    'primary' => 'Primary Navigation'

add_action( 'after_setup_theme', 'my_cool_menu_function' );

Then, in your theme, simply call that menu's position:

wp_nav_menu( array( 'theme_location' => 'primary' ) );
share|improve this answer

Add this to functions.php of your theme. If you don't have one, create it.:

function register_my_menus() {
    $args = array( 
        'menu-1' => __( 'Main Menu' )
    register_nav_menus( $args );
add_action( 'init', 'register_my_menus' );

And this can go anywhere, I have it in header.php (see wp_nav_menu() docs):

$args = array(
    'menu' => 'Main Menu',
    'sort_column' => 'menu_order',
    'container' => 'div',
wp_nav_menu( $args ); ?>
share|improve this answer

This how to include the custom navigation in its simplest form, I believe it picks up the navigation with not identifier:

<div class="access">
  <?php wp_nav_menu(); ?>

There are also basic options that can be passed to the function, here's what I generally use:

    'menu_id' => 'nav',    // target the nav menu
    'container' => '',     // don't wrap the menu in <ul>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.