By Jasim Ahmed / Wordpress
WordPress wp-config.php Tips and Tricks
1. Change Default Table Prefix
By default WordPress assigns “wp_” as a prefix. It is recommended to change this prefix to improve the security. To do that you, need to change the following line in your WordPress configuration.
Table prefix should contain only letters, numbers and underscore without any special characters like $.
2. Enable Debugging in WordPress
WordPress debugging mode allows you to show the details of errors on the screen when the site is being accessed on the browser. We can enable WordPress debugging by adding following lines in wp-config.php:
The above code will generate a log file in the wp-content directory of your Webroot.
3. Change Site and WordPress URL
You can change Site URLs from “Settings > General” page. But you don’t have access to WordPress site, you can change this by adding following lines in wp-config.php. It improve WordPress performance a little.
4. Disable File Editing From wp-admin
You can access all theme files from “Appearance > Editor” menu. Similar, you can access the plugin files from “Plugins > Editor”. You can quickly change code there. Now if you want to disable this by security reason using this code in wp-config.php file
Similar if you want to disable theme and plugin update form wp-admin can use this code.
5. Bypass FTP Connection Information
Sometimes WordPress need FTP connection information on plugin installation or WordPress upgrade. To bypass this you can use this code in wp-config.php:
6. Post Revisions On/Off
WordPress automatically saves the content when editing it online. Default frequency of this autosave is 60 seconds. You can modify the interval to any time in seconds by adding the below code in wp-config.php:
WordPress saves the post/page as a revision when editing it online. This will help you to restore the post/page to the previous versions. you can define the number of revisions WordPress stores for each post/page by adding this code in wp-config.php:
You can disable the post revisions by adding this code wp-config.php:
7. Increase or Decrease PHP Memory
It is a big headache for WordPress users. PHP memory can be increased for your WordPress application by adding following lines:
By default WordPress allocates 40M PHP memory for single installation and 60M for multisite installation.
If needed, you can set a maximum memory limit as well using the following code:
8. Change wp-content Folder Path
WordPress entire theme, plugins and media files are stored under “wp-content” folder. To change this need to add following code in wp-config.php:
Assume you want to move “/wp-content” folder to “/dev/wp-content”.
9. Change Uploads Folder Path
All media files in WordPress are stored inside the folder named “Uploads”. You can change this any name you want like.
10. WordPress Trash Box Timing
By default, if user deletes posts, pages, comments, etc., it is sent to Trash box where WordPress automatically deletes them after 30 days. To change this, you can add following line to modify the value of days as per your need. In the following example, we have decreased it to 7 days.
then you can disable it by adding the function below:
Using zero means it’ll will be deleted permanently.
11. Automatic Database Repair
WordPress has a feature to automatically optimize and repair WordPress database from version 2.9. To enable this feature you need to add the below code in wp-config.php:
After adding this, you need to visit the following URL to optimize and repair WordPress database.
12. Disable Automatic Updates
WordPress 3.7, Automatic Updates was introduced. By default, minor core releases and translation files are used to update. To disable this feature, use the following lines in wp-config.php:
by default, automatic updates do not work with major releases, but you can enable/disable any core updates defining WP_AUTO_UPDATE_CORE as follows:
13. Override File Permissions
If your host has permissions WordPress allows you to override file permissions for all user files. You need to add the following code to your wp-config.php file.
14. Error Log Configuration
An easy way to enable basic error logging for your WordPress site. it create a file called “php_error.log”, make it server-writable, and place it in the directory of your choice.
15. Enable WordPress Caching
Adding following code in the wp-config.php file to turn on the WP-Cache.
17. Enable Multi-Site Network
WordPress 3.0 WPMU was merged into WordPress core. If you want to enable multisite functionality then you need to add the following code to your wp-config.php file.
After adding this code, there will be a new page in your wp-admin located in “Tools > Network”.