If you have worked with WordPress for any considerable time, you have probably run into to dreaded Fatal error: Allowed memory size… error message. And if you haven’t, you will.
This error message is caused by your WordPress site using more memory that the server allows to be allocated to PHP. So if your server is configured to only allocate 8MG(as can be typical) and your site needs more that 8MB or memory resources, you’ll see this puppy.
There are several ways to fix this issue. One is to change the php.ini file to increase memory size. The problem with this is that some hosts don’t allow this, so you may need to contact them about increasing the PHP memory for you.
Another way is to change the wp-config.php file. This is the file that is created during your WordPress install.
While this is perfectly acceptable to do, I like to keep all of my changes within the theme that I am working with. Call if obsessive data management, if you’d like.
So whenever I need to bump up my site’s memory, I add to following code to the functions.php file in my active theme:
That’s it. Keep in mind that should you change themes this bit of code will no longer be applicable. That being said it is very rare that I do a redesign, change themes to the new theme, and continue to have a memory issue. But it can happen.