• Hello,

    I’m having problems getting custom menus to work properly in WordPress 4.0. It seems like whatever worked before just doesn’t anymore, and I’m finding myself unable to complete a custom theme I’ve been working on due to this. In this theme, I’m supposed to use three custom menues, all appearing on the same page (As Header, Main Menu and Footer menues). My code goes as follows:

    On functions.php I have this:

    /***********************************************************************
    **                Registering the menus used on site                  **
    ***********************************************************************/
    
    register_nav_menus( array(
    	'top_menu' => 'Top header menu.',
    	'main_menu' => 'Main site menu. Allows dropdowns.',
    	'footer_menu' => 'Footer menu',
    ) );

    While, in order to call the menues on header.php and footer.php I have this:

    <?php wp_nav_menu( array('menu' => 'top_menu')); ?>
    <?php wp_nav_menu( array('menu' => 'main_menu')); ?>
    <?php wp_nav_menu( array('menu' => 'footer_menu')); ?>

    This worked perfectly before wordpress 4.0 came along. Now it just won’t work. I can see the menues in the admin panel and set custom menues to each spot, but when I open the themes I get the same menu on all three places, even when my back-end states each menu has been set differently. It doesn’t make sense, and it seems broken to me.

    Furthermore, I tried debugging the issue by changing the menu calls to:

    <?php wp_nav_menu( array('menu' => 'top_menu', 'theme_location' => '__no_such_location', 'fallback_cb' => false)); ?>

    Thus eliminating all fallbacks from the menu. The result? No menus are printed whatsoever.

    I’ve seen a supposed ‘fix’ that consists on putting an AAA before your menu names on the admin, but I can’t really tell a client to do that for their custom theme and, even then, that’s just a hack that tries to get around the issue of WP menus not working by setting a menu as the absolute first one, and I fear it wouldn’t work for me anyway since I need to display three different menus on the same theme.

    Am I missing something here? Have I been doing this wrong all along since I started working with WP, or did WP4.0 really mess up the menues? Is there a way around this at all, since the AAA hack won’t even work for what I need?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_nav_menu() broken in 4.0?’ is closed to new replies.