Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The main menu on my site contains about 30 items, and I am no longer able to save it. This seems to be a fairly common problem with bigger menus in Wordpress. I am on a dedicated server with very generous settings for PHP memory and execution time, but past a certain size, I just can't get menus to save.

So, I need an alternative to Wordpress's built-in menu system. I want to keep the setup as flexible and quick to edit as possible. I can edit a flat file if need be, but the easier the better.

Idea #1

Copy the menu's HTML into a static template file and replace calls to wp_nav_menu() with get_template_part('my_menu_file').

Problem

I don't know how I would add current-menu-item class to the current menu item. I could live without the other utility CSS classes added by wp_nav_menu, but current-menu-item is pretty important.

Idea #2

Since the menu is hierarchical, I could create one menu for the top-level items and separate menus for each dropdown, and then use a plugin like UberMenu to attach the submenus to their top-level items.

Problem

I would have to do a lot of tweaking and retrofitting to get the plugin-generated menu to look identical to the current menu.

Are there other approaches or solutions that would make sense here?

share|improve this question
1  
Why not just look into the underlying issue? Your PHP ini settings (either max_input_time, max_input_vars or max_input_nesting_level) need to be adjusted. –  chrisguitarguy Jan 4 '13 at 21:37
    
@chrisguitarguy What are your recommended values for max_input_vars and max_input_nesting_level? –  supertrue Jan 4 '13 at 21:40
1  
No idea. See what they are now, raise them until the menu begins to work. If it doesn't, look elsewhere. :) –  chrisguitarguy Jan 4 '13 at 21:50
add comment

1 Answer

As @chrisguitarguy said, you can likely fix this via your php.ini settings. Specifically, I've run into this issue with a client which was solved by setting max_input_vars to something like 2000.

In some cases though, menus can reach untenably large sizes and you may want a different way to manage them simply from a usability standpoint. For example, adding an item to a menu with hundreds of items can be a chore if you have to drag them up pages of scrolling. A potential solution in this case may be to break the menu into separate menus for each top level item, and then concatenate them into a single menu by removing the outer ul and combine them. The obvious drawback to this method is that the number and order of top level items is fixed, unless you provide some way to separately set and dynamically register your menus.

$menu_one = wp_nav_menu(
    array(
        'echo' => 0,
        'container' => false,
        'menu_class' => '',
        'menu_id' => '',
        'theme_location' => 'menu_one'
    )
);

$menu_two = wp_nav_menu(
    array(
        'echo' => 0,
        'container' => false,
        'menu_class' => '',
        'menu_id' => '',
        'theme_location' => 'menu_two'
    )
);

$menu_one = preg_replace( array( '#^<ul [^>]*>#', '#</ul>$#' ), '', $menu_one );
$menu_two = preg_replace( array( '#^<ul [^>]*>#', '#</ul>$#' ), '', $menu_two );

echo '<ul id="main-menu">' . $menu_one . $menu_two . '</ul>';
share|improve this answer
3  
You can just set 'items_wrap' => '%3$s' to avoid the <ul>. –  toscho Jan 4 '13 at 22:21
    
thanks @toscho, should have figured it would be easier than what I was doing. –  Milo Jan 4 '13 at 23:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.