Problem with registering menus – What to do when other solutions aren’t working?

In regard to this comment:

I see – I had things nested incorrectly in my functions.php file – I found that the register_nav_menus() call should not be nested within the theme setup function (function hchw_setup())

To the contrary, inside a callback hooked into after_setup_theme is exactly the right place for calls to register_nav_menus().

Your problem is a syntax error. You have placed your add_action() call inside the callback that it is attempting to hook, and as such, the callback never gets added to the hook:

function hchw_setup() {

// Make theme available for translation
load_theme_textdomain('hchw', get_template_directory() . '/lang');

// Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
//register_nav_menus(array(
//    'primary_navigation' => __('Primary Navigation', 'hchw'),
//    'sub_navigation' => __('Sub Navigation', 'hchw'),
//));


register_nav_menu('primary_navigation', 'Primary Navigation');
add_action('after_setup_theme', 'hchw_setup');


// Add post formats (http://codex.wordpress.org/Post_Formats)
// add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'));

// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style('assets/css/editor-style.css');

/**
 * Custom images size
**/  
// Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
// This is then pulled through to your theme useing the_post_thumbnail('custombig'); 
add_theme_support('post-thumbnails');
  set_post_thumbnail_size(150, 150, false);
  add_image_size('category-thumb', 300, 9999); // 300px wide (and unlimited height)
  add_image_size('postfull', 504, 334); // Blog Post Full-Size
  add_image_size('customfeatins', 248, 165, true); //hp featured inset
  add_image_size('customfeatblg', 290, 192, true); //int featured inset
  add_image_size('customfeed', 136, 90, true); //feed thumbnails
  add_image_size('customparade', 176, 98, true); //logo parade

}

Notice how this is inside the hchw_setup() function?

add_action('after_setup_theme', 'hchw_setup');

You need to move it outside the function:

function hchw_setup() {

// Make theme available for translation
load_theme_textdomain('hchw', get_template_directory() . '/lang');

// Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
//register_nav_menus(array(
//    'primary_navigation' => __('Primary Navigation', 'hchw'),
//    'sub_navigation' => __('Sub Navigation', 'hchw'),
//));


register_nav_menu('primary_navigation', 'Primary Navigation');


// Add post formats (http://codex.wordpress.org/Post_Formats)
// add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'));

// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style('assets/css/editor-style.css');

/**
 * Custom images size
**/  
// Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
// This is then pulled through to your theme useing the_post_thumbnail('custombig'); 
add_theme_support('post-thumbnails');
  set_post_thumbnail_size(150, 150, false);
  add_image_size('category-thumb', 300, 9999); // 300px wide (and unlimited height)
  add_image_size('postfull', 504, 334); // Blog Post Full-Size
  add_image_size('customfeatins', 248, 165, true); //hp featured inset
  add_image_size('customfeatblg', 290, 192, true); //int featured inset
  add_image_size('customfeed', 136, 90, true); //feed thumbnails
  add_image_size('customparade', 176, 98, true); //logo parade

}
// Move me outside the function
add_action('after_setup_theme', 'hchw_setup');

Leave a Comment