How to Increase the WordPress Memory Limit

1. Check Your Current Memory Limit

Before making changes, it’s helpful to know your current memory limit:

  1. Log in to Your WordPress Admin Dashboard.
  2. Go to Tools > Site Health > Info.
  3. Expand the Server section and look for the WordPress Memory Limit.

2. Increase Memory Limit via wp-config.php

Access Your WordPress Files:

  • Use an FTP client (like FileZilla) or your hosting provider’s file manager.
  • Navigate to the root directory of your WordPress installation (where wp-config.php is located).

Edit wp-config.php:

  • Download the wp-config.php file to your computer or edit it directly via your hosting provider’s file manager.
  • Locate the line that says /* That's all, stop editing! Happy publishing. */.

Add Memory Limit Code:

  • Just before this line, add the following code:
define('WP_MEMORY_LIMIT', '256M');
    • This code sets the memory limit to 256 megabytes. You can adjust this value based on your needs and hosting capabilities (e.g., 128M, 256M, 512M).
  1. Save Changes:
    • If you edited the file locally, upload the modified wp-config.php file back to your server.
  2. Check Your Site:
    • Visit your WordPress site to see if the changes resolved your issue.

3. Increase Memory Limit via .htaccess (If Applicable)

  1. Access Your .htaccess File:
    • Using an FTP client or file manager, locate the .htaccess file in the root directory of your WordPress installation.
  2. Edit .htaccess:
    • Add the following lines at the end of the file:
php_value memory_limit 256M
    • Save and upload the .htaccess file if you edited it locally.
  1. Verify Changes:
    • Check your WordPress site again to ensure the memory limit has been increased.

4. Increase Memory Limit via php.ini (If You Have Access)

  1. Access php.ini File:
    • This method depends on your hosting environment. If you have access, locate the php.ini file in your server’s configuration.
  2. Edit php.ini:
    • Add or modify the following line:
memory_limit = 256M
    • Save the file and restart your web server if necessary (some hosting environments require a restart for changes to take effect).
  1. Check Memory Limit:
    • Ensure your site reflects the new memory limit.

5. Contact Your Hosting Provider

If the above methods don’t work or if you’re on a managed hosting environment, you may need to contact your hosting provider. Some hosts restrict how much memory you can allocate, or they may have specific instructions for increasing memory limits.

Additional Tips:

  • Backup Your Site: Always back up your WordPress site before making changes to core files.
  • Monitor Resource Usage: Increasing memory can help with performance issues, but it’s also wise to monitor your site’s resource usage.