WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] nav menu export problem - possible help registering in header (8 posts)

  1. _minimum
    Member
    Posted 1 year ago #

    I am currently creating my first ever full(ish)wordpress template, so forgive my newbness! I have a menu that I created in wp-admin for my template, this seemed the easy way to do it so I didn't create a custom nav menu as that seemed more complex and I was rushing! On my dev box is works fine and various people have reordered/renamed items and it hooks into my theme just fine. However after exporting my theme and xml content to a test server (running same version of wordpress 3.4.1) the menu is ordered correctly in wp-admin appearance>menus but in the actual site pages its in the the wrong order. Though all the menu items are present and correct it's just the order that's wrong. Is this because I need to register this nav menu in some way?

    I have promised delivery of this site to friends so I'm hoping I can just make this nav menu good then go off and learn from the mistakes I have made here!

  2. vtxyzzy
    Member
    Posted 1 year ago #

    If you used Pages in the Custom Menu, it is possible that the menu needs to be assigned in Admin->Appearance->Menus to the correct 'Theme Locations' in the left column.

  3. _minimum
    Member
    Posted 1 year ago #

    thanks vtxyzzy,

    In theme locations it says

    The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.

  4. vtxyzzy
    Member
    Posted 1 year ago #

    I'm a little confused. You said

    I have a menu that I created in wp-admin

    , but the theme does not support menus?

    Please explain how you created the menu and used it if the theme does not support menus.

  5. _minimum
    Member
    Posted 1 year ago #

    Yes I created the menus in wordpress admin tool ie mine.com/wp-admin. I created a menu using the admin tool and on the dev site (Where it is all working OK) also states

    The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.

    So I have just registered a menu in functions.php using the name my original menu for eg myMenuName:

    if ( function_exists( 'register_nav_menu' ) ) {
    register_nav_menu( 'myMenuName', 'My menu name' );

    I'm calling it in my header.php:

    <?php wp_nav_menu(); ?>

    And I can now configure 'Theme locations' on the left of Admin>appearances>menus using myMenuName (There also seems to be a test menu now)

    However my menu navigation on the site still shows in a random order. Is it that this menu just reflect all the pages available and not using anything set up in Admin>appearances>menus

    Sorry for the long post

  6. vtxyzzy
    Member
    Posted 1 year ago #

    I think you need to give wp_nav_menu() the theme_location parameter so it knows which menu to display:

    <?php wp_nav_menu('theme_location' => 'myMenuName'); ?>
  7. _minimum
    Member
    Posted 1 year ago #

    Thanks vtxyzzy that was what I needed to do

  8. vtxyzzy
    Member
    Posted 1 year ago #

    If your problem has been solved, please use the dropdown on the right to mark this topic 'Resolved' so that anyone else with this question can see that there is a solution.

Topic Closed

This topic has been closed to new replies.

About this Topic