WP-config is likely one of the strongest recordsdata in your WordPress website, and it performs an vital function in how WordPress works behind the scenes. There are some very helpful WordPress configuration methods that almost all newbies don’t find out about. On this article, we are going to share a number of the most helpful WordPress configuration methods that can assist you to troubleshoot, optimize, and safe your WordPress website.
How one can Use these WordPress Configuration Methods?
WordPress comes with a strong configuration file known as wp-config.php. It’s positioned within the root folder of each WordPress website and comprises vital configuration settings.
To study extra, see our information on learn how to edit wp-config.php file in WordPress.
All of the finest WordPress internet hosting corporations include 1-click WordPress set up which implies you’d by no means must edit the wp-config.php file through the set up. That is the principle purpose why many customers aren’t acquainted with the facility of this file.
You should utilize the wp-config file to troubleshoot, optimize, and safe your WordPress website.
The wp-config.php file is a strong instrument, and a tiny mistake within the code could make your web site inaccessible. You need to solely edit this file when mandatory and at all times create an entire WordPress backup earlier than making any adjustments,
That being mentioned, let’s check out some helpful WordPress configuration methods that you should utilize in your web site.
1. The Fundamental WordPress Configuration Settings
By default, you simply must fill within the database settings throughout WordPress set up. In case you don’t have a wp-config.php file current, then you can be requested to create one by filling in your database info.
WordPress will attempt to routinely save these settings by producing a wp-config.php file. Nevertheless, if it fails, then you have to so as to add them manually.
To do this, you have to to attach along with your web site utilizing an FTP shopper. As soon as related, you have to to rename the wp-config-sample.php file to wp-config.php.
After that, you may go forward and edit the newly created wp-config.php file. You have to so as to add your database info by altering the next strains:
outline('DB_NAME', 'database-name'); outline('DB_USER', 'database-username'); outline('DB_PASSWORD', 'database-password'); outline('DB_HOST', 'localhost');
Don’t neglect to save lots of your adjustments and add the file again to the server.
2. Including Safety Keys in WordPress
The default WordPress set up routinely provides safety keys to your configuration file. These safety keys are used so as to add an additional safety layer to your WordPress login and cookie authentication.
You possibly can at all times regenerate safety keys if you happen to really feel somebody could also be accessing your web site with out correct authentication. Altering safety keys will sign off all logged in customers.
outline( 'AUTH_KEY', 'put your distinctive phrase right here' ); outline( 'SECURE_AUTH_KEY', 'put your distinctive phrase right here' ); outline( 'LOGGED_IN_KEY', 'put your distinctive phrase right here' ); outline( 'NONCE_KEY', 'put your distinctive phrase right here' ); outline( 'AUTH_SALT', 'put your distinctive phrase right here' ); outline( 'SECURE_AUTH_SALT', 'put your distinctive phrase right here' ); outline( 'LOGGED_IN_SALT', 'put your distinctive phrase right here' ); outline( 'NONCE_SALT', 'put your distinctive phrase right here' );
For extra info, see our article on WordPress safety keys and learn how to use them.
3. Change WordPress Desk Prefix
A typical default WordPress set up provides a wp_ prefix to all WordPress database desk names. Some WordPress safety consultants imagine that altering the desk prefix could make your WordPress database safer.
To do this you, want to alter the next line in your WordPress configuration.
$table_prefix = 'wp_';
In case you are doing this for an present web site, then additionally, you will want to alter the desk prefix in your WordPress database. To do this, see our article on learn how to change the WordPress database prefix.
4. Activate Debugging in WordPress
WordPress comes with a neat debugging characteristic that permits you to see or disguise WordPress errors when in debug mode. To show this on, you have to so as to add this rule in your WordPress configuration file.
outline( 'WP_DEBUG', true );
You may also activate debugging whereas hiding the errors in your web site and saving them in a log file as a substitute. To do this, add the next strains to your configuration settings.
outline( 'WP_DEBUG', true ); outline( 'WP_DEBUG_LOG', true ); outline( 'WP_DEBUG_DISPLAY', false );
It will create a debug.log file inside wp-content folder of your web site and retailer all debugging errors and notices contained in the log file.
5. Altering Your Web site or WordPress Tackle
Usually, you may set your WordPress and Web site URLs from Settings » Common web page. Nevertheless, it’s possible you’ll not be capable of do this if you happen to don’t have entry to your WordPress website, seeing redirect errors, or have simply moved your website.
In that case, you may change your website and WordPress URLs by way of wp-config.php file by including the next strains:
outline('WP_HOME', 'http://www.instance.com'); outline('WP_SITEURL', 'http://www.instance.com');
Don’t neglect to interchange instance.com with your personal area title.
6. Override File Permissions
WordPress permits you to override file permissions in case your host has restrictive permissions for all person recordsdata. Most customers don’t want this, but it surely exists for individuals who want it.
outline('FS_CHMOD_FILE', 0644); outline('FS_CHMOD_DIR', 0755);
To study extra about file permissions, see our article on how-to repair file and folder permissions error in WordPress.
7. Altering Put up Revision Settings
You possibly can disable or change submit revision settings by the configuration file. Listed here are totally different submit revision settings that you should utilize.
You possibly can change how typically WordPress shops an autosave as a revision by including the next line:
outline('AUTOSAVE_INTERVAL', 120); // in seconds
Some articles in your website could have dozens of submit revisions relying on how lengthy it took to put in writing them. In case you suppose that characteristic annoys you, then you may restrict the variety of revisions per submit.
If for some purpose, you wish to disable the submit revisions characteristic altogether (not advisable in any respect), then you should utilize the next code to disable submit revisions.
outline( 'WP_POST_REVISIONS', false );
8. Altering WordPress Trash Settings
WordPress comes with a recycle bin characteristic known as Trash. When a person sends a submit to trash, it’s nonetheless saved in your web site for subsequent 30 days as trash. After that point, WordPress routinely deletes them perpetually.
You possibly can change this conduct by altering the variety of days you wish to maintain the trash.
outline( 'EMPTY_TRASH_DAYS', 15 ); // 15 days
If you don’t like this characteristic, then you may disable it by including the perform under:
outline('EMPTY_TRASH_DAYS', 0 );
Be aware: Utilizing zero means your posts might be deleted completely. WordPress wouldn’t ask for affirmation whenever you click on on Delete Completely. Any unintentional click on may value you…
To study extra, see our article on learn how to restrict or disable automated empty trash characteristic in WordPress.
9. Including FTP/SSH Constants to WordPress Configuration
By default, WordPress permits you to improve WordPress core, themes, and plugins from the admin dashboard. There are some hosts that require an FTP or SSH connection everytime you attempt to improve, or set up a brand new plugin.
Through the use of the codes, you may set the FTP or SSH constants and by no means have to fret about it once more.
// forces the filesystem technique: "direct", "ssh", "ftpext", or "ftpsockets" outline('FS_METHOD', 'ftpext'); // absolute path to root set up listing outline('FTP_BASE', '/path/to/wordpress/'); // absolute path to "wp-content" listing outline('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/'); // absolute path to "wp-plugins" listing outline('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/'); // absolute path to your SSH public key outline('FTP_PUBKEY', '/dwelling/username/.ssh/id_rsa.pub'); // absolute path to your SSH personal key outline('FTP_PRIVKEY', '/dwelling/username/.ssh/id_rsa'); // both your FTP or SSH username outline('FTP_USER', 'username'); // password for FTP_USER username outline('FTP_PASS', 'password'); // hostname:port combo on your SSH/FTP server outline('FTP_HOST', 'ftp.instance.org:21');
Be aware: Don’t neglect to interchange the WordPress path and ftp.instance.com with your personal FTP Host info.
10. Enable Automated Database Restore
WordPress comes with a built-in characteristic to routinely optimize and restore WordPress database. Nevertheless, this characteristic is turned off by default.
To allow this characteristic it is advisable to add the next line to your WordPress configuration file.
After including this, it is advisable to go to the next URL to optimize and restore WordPress database
Don’t neglect to interchange instance.com with your personal area title. You will notice a easy web page with the choices to restore or restore and optimize the database. You don’t have to be logged in to entry this web page.
11. Enhance PHP Reminiscence Restrict
A number of the most typical WordPress errors are attributable to PHP reminiscence exhausted. You possibly can improve the PHP reminiscence restrict by wp-config.php file. Merely paste the code under:
12. Shifting wp-content Listing
WordPress permits you to transfer your wp-content listing. Some consultants imagine that it might assist strengthen WordPress safety.
You have to so as to add the next code to your wp-config.php file:
outline( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/weblog/wp-content' ); outline( 'WP_CONTENT_URL', 'http://instance/weblog/wp-content'); outline( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/weblog/wp-content/plugins' ); outline( 'WP_PLUGIN_URL', 'http://instance/weblog/wp-content/plugins');
Don’t neglect to interchange instance.com with your personal area title.
13. Use Customized Person Tables
By default, WordPress saves all person information within the tables wp_users and wp_usermeta. Through the use of the perform under, you may specify the desk the place you need your person info saved.
outline('CUSTOM_USER_TABLE', $table_prefix.'my_users'); outline('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta');
14. Allow Multi-Web site Community
Every WordPress website comes with a built-in multisite characteristic which lets you create a number of WordPress websites utilizing the identical set up. To study extra, see our full information on learn how to set up and setup WordPress multisite community.
You possibly can allow multisite performance by including the next line to your WordPress configuration file:
15. Securing Your WordPress Configuration File
As you may see, the wp-config.php file comprises actually vital WordPress settings. By default it’s positioned within the root WordPress folder, however you may transfer it. It may be moved outdoors your public_html listing, so customers can’t entry it. WordPress is aware of by default to look in different directories if the recordsdata just isn’t discovered within the WordPress root folder.
You may also add the next code to your .htaccess file to restrict entry to this file.
# Shield wp-config.php <Recordsdata wp-config.php> order permit,deny deny from all </Recordsdata>
We hope this text helped you study some helpful WordPress configuration methods that you simply didn’t know. You might also wish to see our mega checklist of 55+ most wished WordPress suggestions, methods, and hacks that you should utilize in your website.