• Hi, I’m running on 3.4.2 and developing a theme and struggling to get nav menu’s sorted.

    Basically what I want is to register an menu in WordPress, that is set by default when you go to Appearance -> Menu’s. So when the theme is installed there will be e.g. “Main menu” at the top, which then can’t be removed from WordPress.

    I have added add_theme_support('menus'); and:

    function registerNavMenus() {
      register_nav_menus(
        array(
          'a' => 'A',
          'b' => 'B',
        )
      );
    }
    
    add_action( 'init', 'registerNavMenus' );

    I have read about 2 dozen pages on wordpress.org (on theme development) and several blog posts on external pages, and trying a lot, but can’t seem to get it right. What an I doing wrong?
    But for some reason I can’t

Viewing 5 replies - 1 through 5 (of 5 total)
  • which then can’t be removed from WordPress.

    If you want a fixed menu then you shouldn’t be adding a custom menu to this location.

    Thread Starter Richard K

    (@rkorebrits)

    So what should I do? When I say can’t be removed, I mean by an administrator user in wordpress. Like you can add a menu from the GUI, by clicking a plus, and you can then delete the added one. I want a fixed one, presumably set from the code.

    Then I’d suggest using something other than wp_nav_menu() – such as wp_list_pages() or wp_page_menu().

    Thread Starter Richard K

    (@rkorebrits)

    I’m creating a generic theme and want to use custom theme’s, because there will be a main nav that will always need to be set… e.g. wp_list_pages is not what I’m looking for. Is there no way to specify a menu that is there permanently? So can I only specify a theme location that can be bound to a menu that has been made by hand?

    In effect, yes. The whole point behind wp_nav_menu() is that it will allow appropriate users to create a custom menu to be used at that location.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Issues registering nav_menu's from functions.php’ is closed to new replies.