Support » Fixing WordPress » WP 4.0 Broke Main Menu

  • Resolved shainanz

    (@shainanz)


    Hi there,
    Just updated my site to WP 4.0 and all is well except my main menu. It is no longer aligned correctly and it is using a different menu than the one set in WP-Admin. In WP-Admin > Appearance > Menus, everything looks normal, including the location settings.

    See what is happening here.

    The weird thing is that I have another site that is almost identical in terms of structure and menu, and it’s totally fine.

    Any ideas on what’s going on?

Viewing 15 replies - 1 through 15 (of 34 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Plugin Review Team Rep

    Try hard flushing your site cache.

    Thanks, Ipstenu. I’ve refreshed my caching plugin’s caches and done a hard refresh in my browser–is there something else I should be doing?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Plugin Review Team Rep

    Can you share your real URL?

    It’s on a private test site–I haven’t updated my live site yet–but here’s another screenshot. If you look at the HTML being outputted, you can see by looking at the classes and ids of some of the elements that the menu being used in the messed up menu is a different menu than what is being used in the working menu.

    I am calling the menu with <div id="menu2"><?php wp_nav_menu( array('menu' => 'Primary Menu' )); ?></div>, and the correct menu is set as “Primary Menu” in WP-Admin.

    Let me know if you want me to screenshot anything in particular. Thanks for taking a look 🙂

    I was having the EXACT same problem so I did a ton of trying out arguments with different properties and here is what finally worked for me.

    My menu is registered in a custom plugin (could be functions.php), just one menu in this case. The “depth” setting is what seemed to save the day.

    <nav>
    	<?php	wp_nav_menu(array(
    		'menu'            => 'Main menu',
    		'items_wrap'      => '<ul><li>%3$s</li></ul>',
    		'depth'           => 1
    		 ));
    	?>
    </nav>

    Thanks for the idea, vizou. Sadly it did not fix my problem 🙁

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Plugin Review Team Rep

    I was wondering if it’s CSS, which is why I asked to see.

    The weird thing is that I have another site that is almost identical in terms of structure and menu, and it’s totally fine.

    So … what’s the difference? 🙂

    You can see how the live site is structured here. Maybe that will help.

    I don’t think this is relevant to my problem, and it’s a long boring explanation, but the site is actually two WP installs. One is the public-facing one that anyone can access. The other one is a members-only area (the “Trade Orders” link). Both of them have an e-commerce store using the same plugin, but they show different levels of product information (one uses it as a catalogue, the other as an ordering area). For lack of a better idea, they are separate installs.

    The menus on both installs are the same, however; both mostly point to pages on the public-facing site. To do this, I had to use “Links” instead of “Pages” in the menu on the members-only WP install, since the pages themselves sit on the public-facing site.

    The problem is with the public-facing site’s menu.

    But since it is outputting the wrong menu (as you can see from my second link above), I’m pretty sure it’s a PHP problem.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Plugin Review Team Rep

    Sure, but … see we can’t see the output, and we can’t see your php code, and it’s absolute hell to attempt to debug that from screenshots :/

    But what I meant with ‘What’s the difference?’ was ‘What’s the difference with the MENU structure?’

    Is it 100% the same code?

    For lack of a better idea, they are separate installs.

    Multisite perhaps, but that’s neither here nor there 🙂

    It was 99% the same code. I found the 1%.

    The site that worked used:
    <?php wp_nav_menu( array('menu' => 'Main Menu' )); ?>

    The site that didn’t work used:
    <?php wp_nav_menu( array('menu' => 'Primary Menu' )); ?>

    “Main Menu” is what I have in the Menu Name field in Appearance > Menus, and “Primary Menu” is the theme location of the menu. In the older version of WP (still active on my live site so I just verified this), using the theme location in the function worked fine. In WP 4.0, it looks like only the Menu Name works in the function. Since it couldn’t find a menu called “Primary Menu,” it chose the first menu in my list alphabetically.

    Happily resolved! Thanks for the guidance 🙂

    I had about the same issue with a website here and fixed it by changing
    <?php wp_nav_menu( array( 'menu' => 'Primary Menu') ); ?>
    into
    <?php wp_nav_menu( array( 'theme_location' => 'nav-top') ); ?>
    where ‘nav-top’ is the name of the registered nav menu
    register_nav_menu('nav-top', 'Primary Menu');

    I imagine it is not desired to hardcode the menu name and hence you want to just direct to a registered menu, which then needs to be set up by the user.

    I’m having this same issue. I don’t know where to locate the code you all have described above. When I searched in the themes code I didn’t find anything. Where can I find this?

    So it appears that 4.0 has destroyed my nav-bar menu as well. For some reason it only shows a singe option on the nav bar and it happens to be to a page that was deleted some time ago. (not sure why it picked that page). So there is literally no way to navigate my site right now. I purchased a Theme so it’s been a bit difficult to track down the nav bar in but this is what I have found so far.

    In the header.php file I came across this….

    $defaults = array(
    ‘theme_location’ => ”,
    ‘menu’ => ”,
    ‘container’ => ‘div’,
    ‘container_class’ => ”,
    ‘container_id’ => ”,
    ‘menu_class’ => ‘nav navbar-nav top-menu-inset’,
    ‘echo’ => true,
    ‘fallback_cb’ => ‘wp_page_menu’,
    ‘before’ => ”,
    ‘after’ => ”,
    ‘link_before’ => ”,
    ‘link_after’ => ”,
    ‘items_wrap’ => ‘<ul id=”%1$s” class=”%2$s”>%3$s’,
    ‘depth’ => 0,
    ‘walker’ => new Bootstrap_Walker()
    );

    wp_nav_menu( $defaults );

    ?>

    On this theme I am not even sure where to start to track down this issue. If anyone can give any assistance at all – you would be a life and site saver.

    HYLMN, when you include code in your post, make sure to put it in between backticks (see the little note below the textarea for what I mean).

    In terms of your problem, I’m pretty new to PHP and know just enough to get by using WordPress, so I apologise if this doesn’t work! I believe what you need to do is change the line that says 'menu' => '', to 'menu' => 'Name-of-Menu',, where Name-of-Menu is the “Menu Name” that is in the text field in the Appearance > Menus page of your admin area.

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘WP 4.0 Broke Main Menu’ is closed to new replies.