Monday, November 18, 2013

#WordPress | Cannot add new menu items

Problem:
While on a WordPress site, on /wp-admin/nav-menus.php, postback fails to save new menu items and looses the "Main Navigation" selection.

Solution:
Probably you are adding too much menu items.
The navigation page uses one input control per each menu item, which means various POST fields for every menu item you are creating.
E.g. for 82 fields, we need a total of 82*12=984, which is the lowest we can get due to a known PHP limitation settable in the variable max_input_vars.

So what does this mean?
It means that, basically, if you want to be able to add more than 82 menu items, you need to do the following (yourself or by contacting your web hosting provider).

1) make sure php is >= 5.3.9
2) set max_input_vars to a bigger value (e.g. 2000)
3) if suhosin is installed (php security plugin) do 3.1 and 3.2
3.1) set suhosin.post.max_vars to 2000
3.2) set suhosin.request.max_vars to 2000
4) restart the web server (apache or other)

(Very good, detailed source with WordPress plugin):
http://sevenspark.com/wordpress/menu-item-limit

1 comment: