wp-config.php Essentials

May 1st, 2010 by Keith from shrewdies | Filed under Foundation.
wp-config.php is essential to WordPress.

For manual installers, it is set and forget. For automatic installers (SimpleScripts or Fantastico) it is often quite invisible.

Unless something unexpected changes, WordPress 3 adds little different to the way wp-config.php works, so it is still vital to learn a couple of tweaks.

wp-config.php is well documented internally, and the installation instructions tell you what you need to change to make sure that your WordPress installation can see the database.

But, there are two situations that commonly occur in a standard WordPress installation that are far from ideal: memory exhausted messages and excessive page and post revisions.

WordPress Memory Problems

I have mentioned memory problems with WordPress before. Though I only experienced it when upgrading with large plugins like Simple:Press Forum installed, I suspect this can also happen during normal running of some large plugins. Pods CMS has an error report, but as it looks to be a one-off, it could well be due to some other problem.

When I first experienced this problem, I used the temporary solution of de-activating large plugins during the upgrade. However, I later found the permanent solution to be an amendment to wp-config.php, as I noted on the original post, and repeat below.

Excessive WordPress Revisions

When WordPress introduced automatic saving of posts with revisions, it looked perfect for undecided people like myself. Changed a post only to realize you prefer an earlier version? No problem with WordPress, as the default installation settings give you a more or less complete revision history. But this can cause a problem if you frequently revise many posts and pages. Not only can you end up with a massive list of revisions on the edit page, but your database is becoming increasingly cluttered with copy upon copy of the same text – an absolute nightmare if you ever need to directly search or edit the database.

Many people hate the whole idea of revisions, and turn the feature off. I like to keep some recent versions, so I set the number to 3. Whichever you choose, you need to include a step in your installation routine to change the default setting by amending wp-config.php.

wp-config.php Changes

All you need to do is add the following two lines to wp-config.php. It shouldn’t matter where you put them, but for convenience I add them before the line that includes “stop editing”.
define('WP_MEMORY_LIMIT', '64M');
define('WP_POST_REVISIONS', 3);

Tags: ,


Leave a Reply

Allowed tags: & <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>