Increase WordPress PHP max input variables

The PHP max input variables (or max_input_vars value) is the maximum number of variables your server can use for a single function. To work correctly with modern WordPress themes, we recommend setting this value to 3000. If the setting is too low, you may experience problems such as lost data and disappearing widgets.

Check your PHP Version

Before modifying anything, it's useful to check what version of PHP you're using. Older versions, such as 5.x, are often the default used by shared hosts for compatibility reasons. They might also limit max_input_vars to around 1000, even if you specify a higher value using the steps described in this article.

To check your version of PHP, from the WordPress Dashboard:

  1. Select Tools > Site Health.
  2. Click the Info tab.
  3. Scroll down to Server and click to expand.
  4. Look for the value PHP version.

Reputable shared hosts will let you modify the PHP version yourself within their administrative control panel. We recommend using PHP Version 7.3 or higher for modern WordPress themes.

How to increase PHP max input variables

Method 1: Edit the php.ini file

Many shared hosts prohibit you from having direct access to the php.ini file. Only use this procedure if you can access the file, otherwise, skip to the next method.

  1. Locate the php.ini file. Search your web host’s knowledge base for php.ini and you should come up with where to find it.
  2. Open the file and locate the line of code that reads max_input_vars = N, where N represents the numeric value currently specified.
  3. Set the value to your desired limit, for example, max_input_vars = 3000;.
  4. Save the file and exit.

Method 2: Edit the .htaccess file

  1. Locate the .htacess file. This is normally stored in the root folder of your WordPress installation. If you can't locate it, it might be because it is hidden. Most text editors have a menu option to Show hidden files or Hide invisible files, or similar- the exact location and label of the menu item will differ depending on the application you're using, so consult your software vendor's documentation for more information.
  2. Open the .htacess file.
  3. Add the code php_value max_input_vars 3000 on a new line following the code # END WordPress. If you add the code before # END WordPress your WordPress installation may overwrite it.
  4. Save the file and exit.

Verify the new PHP max input variables

Once you have modified max_input_vars to the new value, you can confirm the change from the WordPress Dashboard:

  1. Select Tools > Site Health.
  2. Click the Info tab.
  3. Scroll down to Server and click to expand.
  4. Look for the heading PHP max input variables. The figure here should now match the new value.

Increase WordPress memory limit

Sometimes when trying to perform an action in WordPress, such as activating a plugin, you might get an error that looks like this:

Fatal error: Allowed memory size of 987654321 bytes exhausted (tried to allocate 12345 bytes)

If you're running resource-intensive plugins or themes, there may come a time when you find yourself hitting this error. Basically, it just means that the server needed more memory to perform the task than was allocated. The error specifically relates to memory for PHP, which is the language that WordPress runs on. The solution is to increase the amount of memory allocated to PHP.

Understanding WordPress memory allocation

Before you go changing your PHP memory allocation, it's really important to understand two key points.

Firstly, there is memory allocation for PHP, then there is an allocation of how much of that PHP memory can be used by WordPress. If your server is solely dedicated to hosting a WordPress website, then typically these values would be the same. However, you can allocate less PHP memory to WordPress specifically if you were running other PHP applications on your server. WordPress memory can only be increased while it is less than the PHP memory allocation - otherwise increasing the WordPress memory limit will do nothing.

The second thing to understand is that both the PHP and WordPress memory allocations don't refer to total memory, but rather the amount of memory allocated per script that is run. If multiple scripts are running, then the memory allocated will be multiplied by the number of scripts. This means that specifying a larger-than-necessary memory allocation may cause your server to run out of memory. In this case, more is not necessarily better - just enough to ensure the task no longer triggers a memory exhausted error is best.

How to increase the WordPress PHP memory limit

If you're using a hosting service, changes to these files should take effect immediately. If you're running your own server, you'll need to restart both PHP and the web server for changes to take effect, or you can reboot.


Let's look at increasing the PHP memory limit first, since WordPress can't allocate more memory than is specified here. Depending on your host, you may or may not have access to this file, and you may or may not be able to create your own. Search your web host's knowledge base for php.ini and you should come up with where to locate the file.

Once you've located the file, it's simply a case of adding the following line (or editing the existing one if it is already specified). In this example, we're allocating 128MB of memory.

memory_limit = 128M


If you don’t have access to your php.ini file, sometimes you can use your .htaccess file to set the memory limit:

php_value memory_limit 128M


Now that we've increased the PHP memory limit, we can specify how much of that memory is allocated for use by WordPress. The default memory allocated to WordPress is 32MB but we can increase that by editing the wp-config.php file located in the root folder of your WordPress installation. If you have WooCommerce installed, they recommend a memory limit of 64MB, some complex themes will require a limit of 96MB and most websites shouldn't need more than 128MB. The best approach is to increase the limit incrementally until the error goes away.

Locate the line of text that reads /* That's all, stop editing! Happy publishing. */ and place the following code just above that line. In this example, we're allocating memory of 128MB.

define('WP_MEMORY_LIMIT', '128M');

The WordPress Dashboard is more memory intensive than your website, so it may be that it's just the WordPress administration area than needs more memory rather than your website. You can allocate memory for the WordPress administration area using the following code. This can be specified in addition to the example above and should always be a higher value. Here we're allocating 256MB memory for WordPress administration, but remember that your PHP memory needs to be the same or higher than this value for it to work.

define('WP_MAX_MEMORY_LIMIT', '256M');

If you've been experimenting with getting the correct memory allocation to resolve a memory exhausted error, you may need to go back and amend the memory limit in the php.ini file. If your server is used solely for your WordPress website, then the PHP memory allocation and the WordPress memory allocation should be the same.