Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Please help with menu registeration:

I have followed this guide (http://codex.wordpress.org/Navigation_Menus) step by step.

Added the following code to functions.php:

function register_my_menus() {
  register_nav_menus(
    array('header-menu' => __( 'Header Menu' ) )
  );
}

add_action( 'init', 'register_my_menus' );

But the guide says that this will make the menu appear in the Appearance -> Menus admin screen in the "Theme Locations" box as "Header Menu".

When I go to Appearance -> Menus everything is greyed out and there is no option of "Theme Locations"

share|improve this question
    
Add a screenshot of wp-admin/nav-menus.php. And do something with your other orphaned questions. –  toscho Feb 26 '12 at 4:49
add comment

1 Answer

up vote 1 down vote accepted

You don't need to add any action to register your Nav Menu. Here are some quick steps for you to get your Wordpress Nav Menu to work...

Register Nav Menu

if (function_exists('register_nav_menu'))
{
    register_nav_menu('header_menu', 'Header Menu');
}

Define and Use Nav Menu in your Theme: Usually we place the Menu DIV code in header.php file; so I assume yours is also in header.php file. Open that file and locate the DIV container where you wish your Wordpress NAV menu to appear. Here is a sample from one of my recent Wordpress themes for your ready reference:

<div class="css-nav" >

<?php wp_nav_menu( array(
    'sort_column' => 'menu_order',
    'theme_location' => 'header_menu',
    'menu_class' => 'css-menu',
    'title_li' => '<div class="l"></div>',
    'link_before' => '<span class="l">',
    'link_after' => '</span>'
) ); ?> </div>

Once you add this code, go to your WP Admin - Menus. Create a new Menu, if you don't have any yet. As soon as you create a menu, you should see "Theme Location" meta box to the left side of your Menu Item arranger area.

I hope this helps. :-)

Cheers,

Ruturaj.

share|improve this answer
    
+1 for a well-formatted, good answer from a new user. Welcome to WPSE. :) –  Jared Feb 26 '12 at 5:09
2  
function_exists('register_nav_menu') doesn't do anything useful: nav-menu.php is loaded before the theme’s functions.php (see wp-settings.php). 'sort_column' and 'title_li' are not valid arguments. –  toscho Feb 26 '12 at 5:28
    
Thanks...This works! Finally! Documentation at Wordpress could use a serious update –  php-b-grader Feb 26 '12 at 5:38
add comment

Your Answer

 
discard

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.