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?

3 s
3

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' ) );

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *