Earlier we have talked about 10 Most Valuable WordPress Configuration Tricks to Make Your WordPress Experience Better. Today we will talk about some more configuration tricks that you should know. 

There are some very useful WordPress configuration tricks that most beginners don’t know about. In this article, we will share those WordPress configuration tricks that will help you optimize your WordPress site.

1. Adding FTP/SSH Constants to WordPress Configuration:

WordPress allows you to upgrade the core version and plugins from within the backend. However, some of you might not be able to enjoy the benefits due to the FTP connection issue. Simply update your wp-config file with the codes below, you can set the FTP or SSH constants and never have to worry about it again.

define('FS_METHOD', 'ftpext'); // forces the filesystem method: "direct", "ssh", "ftpext", or "ftpsockets"
define('FTP_BASE', '/path/to/wordpress/'); // absolute path to root installation directory
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/'); // absolute path to "wp-content" directory
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/'); // absolute path to "wp-plugins" directory
define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub'); // absolute path to your SSH public key
define('FTP_PRIVKEY', '/home/username/.ssh/id_rsa'); // absolute path to your SSH private key
define('FTP_USER', 'username'); // either your FTP or SSH username
define('FTP_PASS', 'password'); // password for FTP_USER username
define('FTP_HOST', 'ftp.domain.tld:21'); // hostname:port combo for your SSH/FTP server

Of course here you should replace the constant values with your actual credentials. In most cases, “localhost” is the correct value and does not need changed.

2. Disable Corn Time and Time Out:

By default, the wp-cron.php fires on every page load, which on high-traffic sites can cause problems. If a site doesn’t have enough PHP workers, sometimes a request will come in, WordPress will spawn the cron, but the cron has to wait for the worker, and therefore just sits there. A better approach is to disable WP-Cron and use the system cron instead. This runs on a pre-defined schedule.

To disable WP-Cron, add the following to your wp-config.php file:

define('DISABLE_WP_CRON', true);

If you have a site with high traffic, you can reduce the server resources by limiting the frequency. Make sure a cron process cannot run more than once every WP_CRON_LOCK_TIMEOUT seconds.

define( 'WP_CRON_LOCK_TIMEOUT', 120 );

3. Change Site and WordPress URL:

By default, these two configurational definitions are not included in the wp-config.php file, but they should be added to improve performance. Adding these two definitions in your site’s wp-config.php file reduces the number of database queries and thus improves site performance. You can change the URL of your website with the following code:

define('WP_SITEURL', 'http://www.example.com');
define('WP_HOME', 'http://www.example.com');

An alternative method is to use the SERVER variable that sets these values dynamically.

define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] );
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] );

4. Allow Automatic Database Repair:

When one of your database becomes corrupt, it can cause a huge problem. Users can often not able to login when the database is corrupt. Though WordPress comes with a built-in feature to automatically optimize and repair WordPress database. However, this feature is turned off by default. You can enable this by adding the following define to your wp-config.php file only when the feature is required.

define('WP_ALLOW_REPAIR', true);

Inside your browser, enter this address:

{your website’s domain}/wp-admin/maint/repair.php.

Once you are done repairing and optimizing your database, make sure to remove this from your wp-config.php.

5. Enable Error Log Configuration:

You can easily create a simple error log for a WordPress powered website by using wp-config.php file. Create a file called “php_error.log”, make it server-writable, and place it in the directory of your choice. Then edit the path in the third line of the following code and place into your wp-config.php file:

@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/home/path/domain/logs/php_error.log');

This is especially useful for those who have no access to the php.ini file.

6. Turning Off Backend File Editing:

By default, WordPress enables admin-level users to edit plugin and theme files from within the WordPress Dashboard. The following code will block users being able to use the plugin and theme installation/update functionality from the WordPress admin area.

define('DISALLOW_FILE_EDIT', true);

Placing this line in wp-config.php is equivalent to removing the edit_themes, edit_plugins and edit_files capabilities of all users.

7. Set Autosave Intervals:

By default, WordPress automatically saves revisions of your work every 60 seconds. You may want to increase this setting for longer delays in between auto-saves, or decrease the setting to make sure you never lose changes. To increase or decrease add the following line:

define( 'AUTOSAVE_INTERVAL', 120 ); // Seconds

8. Disable Automatic Updates:

From version 3.7, WordPress has an automatic update for the core. If you want to disable these features, add the following line in wp-config.php:

# Disable all core updates:
define( 'WP_AUTO_UPDATE_CORE', false );

9. Enable WordPress Caching:

To improve the performance of your website, just add the following code in the wp-config.php file, it will turn on the WP-Cache.

define('WP_CACHE', true);

10. Lock the Configuration File:

We all know wp-config.php is one of the most important WordPress files. So, this file needs extra security. Add the following code to your .htaccess file to prevent hackers from accessing your wp-config file.

# protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all
</files>

Conclusion

Don’t forget to create a backup of any file you want to edit. So, if you make a mistake, you can easily resolve this problem with a backup file. You can also read Understanding the WordPress wp-config.php File before editing the wp-config.php file. And finally, always use the latest version of WordPress and all of your installed themes and plugins. Keep safe your login and password credentials which you are using and change them periodically.

We hope this article helped you learn some useful WordPress configuration tricks that you didn’t know. We will surely come with more WordPress configuration tricks. In the meantime, just check out our WordPress Tips section.

Also check our previous article on WordPress Configuration Tricks. If you have any queries in your mind, do let us know in the comments section and we will be more than happy to help you out.

How to Enable HTTPS (SSL Certificate) For a WordPress Website
How to Add Custom JavaScript and Styles in WordPress

Leave a Comment

Your email address will not be published. Required fields are marked *