If you are going to add too many menu items in your WordPress then beware, on saving your menu you will lost menu items that are beyond WordPress menu items limit. This thing had happened to us and we did a lot of extra work to add those menu items again but only after increasing this limit.
This limit is not imposed by WordPress but by your web hosting server because of some security reasons. In PHP, there is a thing called post vars that controls menu items. By default maximum post vars are much limited as most of the websites require only a few menu items. But if you are running a big news website, or an eCommerce website most probably you will need to have several menu items in your menu.
It is very easy to increase number of post vars using php.ini
All you need to do is adding a piece of code in your php.ini file. Keep in mind that different web hosts support different kind of methods and we have listed all here;
To increase input_vars add the following code in your php.ini file
max_input_vars = 3000;
If your server is using Suhosin
If your hosting server has Suhosin running, it will affect your WordPress menu limit and you need to add the following code in your php.ini file;
suhosin.post.max_vars = 5000
suhosin.request.max_vars = 5000
If above given workarounds don’t work, you can also try some other;
1.Add php.ini in wp-admin folder
Create a php.ini file with the below given code and put it into wp-admin folder
max_input_vars = 3000;
2.Add .user.ini file
Create a file .user.ini and add the following code to it and try placing it in WordPress root or in wp-admin folder;
max_input_vars = 5000;
Hopefully one of the method should work for you.
If you are unable to create a php.ini file?
However, it would be a great bullshit if any host doesn’t allow creating custom php.ini files.
Get your Web Hosting support team and ask them to add the code to php.ini file or ask them to enable custom php.ini creation. It may be possible that your host deny to add custom code to php.ini file or to enable creation your own php.ini file. In that condition you should consider switching to a better host as you are free to transfer your website anytime to any host.
Tip – Keep your WordPress menu backed up if it is very large
Keep backup of your menu every time you make a change. There is only one plugin that lets you take backup of WordPress menus and you can import export WordPress in emergencies.
- Install and activate the plugin
- Go to Tools > Export and here you will find an additional option of exporting Menu items added by this plugin
- Choose this option and generate xml export file and save it to your PC
- You can import this file if you lost your menu items in future due to any reason. You can import it in a way you import your WordPress XML back file (tools > Import > WordPress > Upload XML file generated by the plugin)
Download Mexu Exporter Plugin