Magic of wp-config.php

If you are a WordPress dev, then there are high chances that you have heard about wp-config.php file. It is the heart and soul of any wordpress installation, still it holds the switch for large number of WordPress functionalists but only a few are know a niche user. Lets dig into wp-config.php, and see what treasure can we find for ourself that can make our life easier:-

 

1. Change wp-content  folder:- There are two reasons why would you want to do that. First and foremost is security. All the hackers around the globe know that most of the WordPress blogs have this  important folder  call “wp-content” on the web server. Since they know one thing, and other de facto WordPress things, they can use these information and combined they can make a havoc out of it. You can change the name of wp-content folder and make hacker’s task a little difficult.

 

[raw]define( ‘WP_CONTENT_DIR’, dirname(__FILE__) . ‘/new-wp-content/’ );[/raw]

 

2. Limit Post Revision Count:- Don’t tell me you don’t know what does it mean. In WordPress, each and every post and page you create, is saved in the database. Not just that, every time you make a change to any post a new copy of that post gets stored in database making the site heavier.  Say, if we make 50 small changes on a single post and after every change we either publish or save the post as draft, in that case our database will  be containing 50 copies of single post. Of, course we don’t need that much copies. Only as minimum as 3 copies will be enough for us. We can use this code to limit number of revisions.

 

[raw]define( ‘WP_POST_REVISIONS’, 3 );[/raw]

 

3. Switching wp-debug:- WordPress sites by default do not show code related error messages or warnings. It is so because front end user doesn’t need to show these error and because it leaks crucial information to the hackers. So, even there is an extreme blunder done in the code, sites will not show any error message, But when you want to eliminates those error you need to knwo what those errors are? For that matter of time you can turn debug mode ON by editing wp-config file:-

 

[raw]define(‘WP_DEBUG’, true);[/raw]

 

When done, turn it off again like this:-

 

[raw]define(‘WP_DEBUG’, false);[/raw]

 

4. Disabling updates:- Sometimes you would want to disable automatic updates for WordPress core, plugin or themes. This can be easily done by editing wp-config file.

To disable automatic update nag of WordPress core:-

 

[raw]define( ‘WP_AUTO_UPDATE_CORE’, false );[/raw]

 

To disable update nag of Themes and Plugins:-

 

[raw]define( ‘DISALLOW_FILE_MODS’, true );[/raw]

If you are a WordPress dev, then there are high chances that you have heard about wp-config.php file. It is the heart and soul of any wordpress installation, still it holds the switch for large number of WordPress functionalists but only a few are know a niche user. Lets dig into wp-config.php, and see what treasure can we find for ourself that can make our life easier:-

 

1. Change wp-content  folder:- There are two reasons why would you want to do that. First and foremost is security. All the hackers around the globe know that most of the WordPress blogs have this  important folder  call “wp-content” on the web server. Since they know one thing, and other de facto WordPress things, they can use these information and combined they can make a havoc out of it. You can change the name of wp-content folder and make hacker’s task a little difficult.

 

[raw]define( ‘WP_CONTENT_DIR’, dirname(__FILE__) . ‘/new-wp-content/’ );[/raw]

 

2. Limit Post Revision Count:- Don’t tell me you don’t know what does it mean. In WordPress, each and every post and page you create, is saved in the database. Not just that, every time you make a change to any post a new copy of that post gets stored in database making the site heavier.  Say, if we make 50 small changes on a single post and after every change we either publish or save the post as draft, in that case our database will  be containing 50 copies of single post. Of, course we don’t need that much copies. Only as minimum as 3 copies will be enough for us. We can use this code to limit number of revisions.

 

[raw]define( ‘WP_POST_REVISIONS’, 3 );[/raw]

 

3. Switching wp-debug:- WordPress sites by default do not show code related error messages or warnings. It is so because front end user doesn’t need to show these error and because it leaks crucial information to the hackers. So, even there is an extreme blunder done in the code, sites will not show any error message, But when you want to eliminates those error you need to knwo what those errors are? For that matter of time you can turn debug mode ON by editing wp-config file:-

 

[raw]define(‘WP_DEBUG’, true);[/raw]

 

When done, turn it off again like this:-

 

[raw]define(‘WP_DEBUG’, false);[/raw]

 

4. Disabling updates:- Sometimes you would want to disable automatic updates for WordPress core, plugin or themes. This can be easily done by editing wp-config file.

To disable automatic update nag of WordPress core:-

 

[raw]define( ‘WP_AUTO_UPDATE_CORE’, false );[/raw]

 

To disable update nag of Themes and Plugins:-

 

[raw]define( ‘DISALLOW_FILE_MODS’, true );[/raw]