WordPress Configuration Tricks

Web development forums are flooded with queries like help me convert my website to WordPress. These are posted by people hoping to access a platform with more control and flexibility. The powerful wp-config file is one of the most important elements which helps the CMS work. WordPress configuration tricks that modify this file are helpful in easing website management. Many amateur users will be unaware of the existence of the file.

WordPress Configuration Tricks

These people would not have had to modify the file as they would have installed the CMS through their dedicated WordPress hosting services. However, they must be careful while using these tips as even a minor error can render the interface inaccessible. It will be better if people with technical knowledge of WordPress web development, use these suggestions after creating a backup of their website. 

Let’s now take a look at the tricks;

1. Enable The Debugging Feature

Website owners can turn on a feature that will let them see or hide errors in the debug mode. This debugging feature can be enabled by adding the following line to the configuration file:

define( ‘WP_DEBUG’, true );

Users have the option to enable debugging and hide the errors and save them in a log file. This can be done by creating the log file in the wp-content folder. All the errors and notices related to debugging will be stored in this folder of the interface. The following code will help activate this feature:

define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, false );

2. Modify The Security Keys

When a user installs the core files of WordPress, the security keys are automatically added to the configuration file. These keys help in giving extra protection to the login and cookie authentication features. However, if owners suspect that their interfaces are being accessed in an unauthorized manner, they can change the keys. Alter the code in the wp-config.php file in the manner given below to regenerate all the keys. All logged-in users will be logged out of the website, once this code is activated.

define( ‘AUTH_KEY’,         ‘put your unique phrase here’ );

define( ‘SECURE_AUTH_KEY’,  ‘put your unique phrase here’ );

define( ‘LOGGED_IN_KEY’,    ‘put your unique phrase here’ );

define( ‘NONCE_KEY’,        ‘put your unique phrase here’ );

define( ‘AUTH_SALT’,        ‘put your unique phrase here’ );

define( ‘SECURE_AUTH_SALT’, ‘put your unique phrase here’ );

define( ‘LOGGED_IN_SALT’,   ‘put your unique phrase here’ );

define( ‘NONCE_SALT’,       ‘put your unique phrase here’ );

3. Change The Database Table Prefix

$table_prefix  = ‘wp_’; $table_prefix  = ‘wp_a1234_’;

Only numbers, letters, and underscores can be added to change the line. Existing website owners must modify the prefix in their WordPress database also.

4. Change The WordPress Or Site Address

One of the most convenient features of the open-source CMS is its intuitive admin dashboard. Owners can conduct all modifications to their interfaces through this panel. For instance, if they want to change the WordPress or site address, they can do it by accessing “Settings> General”. However, imagine a scenario when a user is unable to access the dashboard. Then the URLs will have to be changed by using the configuration file. The following lines will help in modifying the addresses:

define(‘WP_HOME’, ‘http://www.xyz.com’);

define(‘WP_SITEURL’, ‘http://www.xyz.com’);

Users must replace “http://www.xyz.com” with their domain name.

5. Alter The Post Revision Settings

The post revision settings can be altered through the wp-config file. This will help owners to nullify changes made to their posts and pages. The following line will reset the time after which WordPress will store an autosave:

define(‘AUTOSAVE_INTERVAL’, 120); // in seconds

Replace 120 with time in seconds of your choice. Use the next line to limit the number of revisions.

define(‘WP_POST_REVISIONS’, 10);

The following code will disable the revision feature:

define( ‘WP_POST_REVISIONS’, false );

6. Turn On Automatic Database Repair

define(‘WP_ALLOW_REPAIR’, true);

Users must replace “xyz.com” with their domain in the following URL and visit it to repair the database.

7. Move The wp-content Directory

define( ‘WP_CONTENT_URL’, ‘http://xyz/blog/wp-content’);

define( ‘WP_PLUGIN_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/blog/wp-content/plugins’ );

define( ‘WP_PLUGIN_URL’, ‘http://xyz/blog/wp-content/plugins’);

People looking to move the directory must add the above code to their wp-config.php file. They must not forget to replace “xyz” in the code with the name of their domain.

8. Manually Doing The Basic Configuration Settings

WordPress users can simply configure the database settings by filling a form during the installation. A wp-config.php file is generated for storing these details. In case, the procedure is not successful, then the basic configuration settings have to be added manually. Use an FTP client to connect to the interface and locate the wp-config-sample.phpfile. Rename it as wp-config.php. Add the details of the website in the following code:

define(‘DB_NAME’, ‘database-name’);

define(‘DB_USER’, ‘database-username’);

define(‘DB_PASSWORD’, ‘database-password’);

define(‘DB_HOST’, ‘localhost’);

Save and upload the file to the server to complete the process.

9. Modify The Trash Settings

All the deleted posts are stored in the trash folder of the installation for 30 days. They are automatically removed from the database after the completion of the period. Users can reset the number of days for which they want to store the trash. Make the desired change like the example given in the following line:

define( ‘EMPTY_TRASH_DAYS’, 10 ); // 10 days

The feature can be completely disabled in the following manner:

define(‘EMPTY_TRASH_DAYS’, 0 );

10. Increase The PHP Memory Limit

The reason for many common errors in WordPress is the exhausted PHP memory. It is possible to increase the PHP memory limit of the installation through a simple method. Just add the following line to ramp up the limit:

define(‘WP_MEMORY_LIMIT’, ‘128M’);

11. Moving The WordPress Configuration File

Even unaware readers, by now would understand the significance of the wp-config.php file. This file is located in the root WordPress folder by default. Moving it to another location would make it difficult to access for unauthorized users. This will not cause any problems as WordPress will search for the file in other directories if it does not find it in the default location. The access to the file can also be controlled by adding the following code to the .htaccess file:

# Protect wp-config.php <Files wp-config.php> order allow,deny deny from all </Files

Conclusion

These WordPress configuration tricks will help website owners in increasing the security of their interfaces and simplifying some common management tasks. However, they must use these tips only after creating a backup of their websites

Leave a Reply