Table of Contents
- Understanding PHP Memory Limit in WordPress
- Check Your Current PHP Memory Limit
- 1. Increasing Memory Limit via wp-config.php
- 2. Increasing Memory Limit via .htaccess
- 3. Increasing Memory Limit via php.ini
- 4. Contacting Your Hosting Provider
- Testing the New Memory Limit
- Troubleshooting Common Issues
- Conclusion
Understanding PHP Memory Limit in WordPress
WordPress is a powerful platform, but sometimes you may encounter memory exhaustion errors, particularly when you’re running resource-intensive themes or plugins. The PHP memory limit controls how much memory a PHP script can consume, and if your WordPress site exceeds this limit, you could see errors such as 'Allowed memory size exhausted'. This guide will walk you through various methods to increase the PHP memory limit in WordPress.
Check Your Current PHP Memory Limit
Before making changes, it's useful to check your current PHP memory limit. You can do this by creating a simple PHP file with the following code:
<?php
phpinfo();
?>Upload this file to your WordPress root directory and access it via your browser (e.g., http://yourdomain.com/memory-check.php). Look for the 'memory_limit' directive in the output.
1. Increasing Memory Limit via wp-config.php
One of the simplest methods to increase the PHP memory limit is by adding a line to your wp-config.php file. Here’s how to do it:
- Access your WordPress site files through FTP or your hosting control panel.
- Locate the wp-config.php file in the root directory.
- Open wp-config.php for editing.
- Add the following line before the line that says 'That's all, stop editing! Happy blogging!':
define('WP_MEMORY_LIMIT', '256M');This sets the memory limit to 256MB, but you can adjust this value based on your needs.
2. Increasing Memory Limit via .htaccess
If you’re using an Apache server, you can also increase the memory limit by editing your .htaccess file. Follow these steps:
- Connect to your site using FTP or your hosting control panel.
- Locate the .htaccess file in the root directory.
- Open .htaccess for editing and add the following line at the end:
php_value memory_limit 256MSave the changes and check if the error persists. Note that this method may not work on all servers, especially if PHP is running as CGI.
3. Increasing Memory Limit via php.ini
If you have access to the php.ini file, this is another effective method. Here’s how to do it:
- Access your server using FTP or your hosting control panel.
- Find the php.ini file (if it doesn't exist, you may need to create one).
- Open php.ini and add or modify the following line:
memory_limit = 256MAfter saving, restart your web server for the changes to take effect.
4. Contacting Your Hosting Provider
If none of the above methods work, you might be on a hosting plan that restricts memory limits. In such cases, it's best to contact your hosting provider. They can either increase the limit for you or guide you through the necessary steps.
Testing the New Memory Limit
Once you have made the changes, revisit the PHP info file you created earlier to confirm that the memory limit has been increased successfully.
Troubleshooting Common Issues
If you’re still facing memory issues after increasing the limit, consider the following troubleshooting steps:
- Deactivate plugins one by one to identify if a specific plugin is causing excessive memory usage.
- Switch to a default WordPress theme to see if the issue is theme-related.
- Check your error logs for more detailed error messages.
Conclusion
Increasing the PHP memory limit in WordPress can be a straightforward fix for memory exhaustion errors. By following the methods outlined in this guide, you can ensure your site runs smoothly and efficiently. Always remember to monitor your site's performance and consider optimizing your themes and plugins to minimize memory usage.

Work with Figmantor
We are an experienced team of experts in AI integrations, WordPress development, Showit customizations, and Next.js web development. From fixing bugs and optimizing speed to converting designs into production-ready platforms, we handle your project end-to-end with premium code quality.
Related Articles
How to Convert Figma to Elementor WordPress — Complete Guide 2026
Learn the complete step-by-step process for converting Figma designs into pixel-perfect WordPress Elementor websites. Covers design audits, asset optimizations, containers, and QA.
ShowitFigma to Showit: Build Stunning Showit Websites From Your Designs
Discover how to transform your Figma mockups into beautiful, drag-and-drop Showit websites. Learn the custom canvas settings, mobile-first design, and WordPress blog styling.
