Software, Development, and WordPress

WordPress 3.1.4 and Custom Menu Regression

WordPress just released version 3.1.4. Overall, it’s a solid release but if you’re working with a theme that has support for multiple custom menus, then you may notice a regression with custom menus after you upgrade the application.

Specifically, all custom menu locations that do not contain a menu actually display all pages on the site.  For example, if your Menu admin panel looks like this (notice three custom menus, two of which are empty:

Then your navigation area likely looks something like this (notice two menus displaying all content):

In order to fix this, you need to provide one extra argument in each place the custom menu is called. Locate the calls to wp_nav_menu in your code. You should find something that looks like this:

wp_nav_menu(
  array(
    'sort_column' => 'menu-order',
    'menu_class' => 'nav clearfix fl',
    'container_id' => 'menu_top',
    'container_class' => 'menu clearfix fl',
    'show_home' => 0,
    'theme_location' => 'top-menu'
  )
);

Add an argument to the array that instructs the system not to use a fallback function. The final code should look like this:

wp_nav_menu(
  array(
    'sort_column' => 'menu-order',
    'menu_class' => 'nav clearfix fl',
    'container_id' => 'menu_top',
    'container_class' => 'menu clearfix fl',
    'show_home' => 0,
    'theme_location' => 'top-menu',
    'fallback_cb' => false
  )
);

This will prevent WordPress from defaulting to a menu. For more information on custom menus, check out the codex.

6 Comments

  1. Jeremy Myers

    And where might this code be found? I checked everywhere I can think of, and cannot find it.

    • Tom

      Depends on the theme. Not all themes use custom menus (or some have the parameter for the fallback already set).

      Which theme are you using?

  2. Jeremy Myers

    Standard Theme.

    I upgraded to 3.2 without a problem. A friend of mine has the problem, and he is also using ST, and he asked me what he could do to fix it.

    I submitted a ticket over at 8bit.io

  3. Jeremy Myers

    I found it in standardtheme.php

    Now I will try the fix suggested above, and see if it works.

    • Tom

      Cool – we’ve also got a lengthy tutorial in doing this for Standard here.

      • Jeremy Myers

        Cool. That all worked. Initially, I forgot the commas, got a parsing error, and was not able to log in to the dashboard. Oops. So uploaded the standardtheme.php via FTP, and made sure I added the commas. Very important! Ha ha!

        Now all works well. Thanks!

Leave a Reply

© 2020 Tom McFarlin

Theme by Anders NorenUp ↑