15 Configuration Tricks Of WordPress Every Developer Should Know

15 Configuration Tricks Of WordPress Every Developer Should Know

Are you someone who is working as a WordPress developer for a long time? OR Are you someone who is an owner of a very successful IT organization who provides WordPress solutions? Then, you must be knowing about the wp-config.php file.

The wp-config.php is one of the most powerful files in the whole WordPress ecosystem, as it plays a very important role in how WordPress works behind the scenes.

Any WordPress developer has to work with this file day-in & day-out and therefore, he/she should be aware of the tricks and tips that can be helpful while working with WordPress Configuration File.

Most of the beginners don’t know how to work in a smooth manner with wp-config.php file and therefore, they face a lot of problems while dealing with any WordPress projects.

Taking this scenario into consideration, today we’re going to provide with 15 very useful WordPress configuration tricks which will ease out all your problems.

How To Use WordPress Configuration Tricks?

Before going into the details of WordPress Configuration Tricks, you need to be aware of how to use these tricks.

The wp-config.php file is located inside the root folder of every WordPress website and it comprises of very important configuration settings.

Most of good WordPress hosting providers come with the 1-click installation process and the user never has to worry about setting up wp-config.php file. Due to this kind of situation, most of the developers are not familiar with the detail insights about this powerful file.

However, you should be very careful while making any kind of edits to the wp-config.php file. The reason behind that is, a tiny mistake in the code can make your website inaccessible.

So, whenever you’re making any changes to this file, please remember to take a backup.

Now, coming to point of configuration tricks, you need to go to wp-config.php file and then, make the necessary edits. So, be very attentive while following any of these tricks.

WordPress Configuration Tricks

  1. Basic Settings
  2. Adding Security Keys
  3. Changing WordPress Table Prefix
  4. Turning On Debugging In WordPress
  5. Changing Your Site & WordPress Address
  6. Overriding File Permissions
  7. Changing Post Revision Settings
  8. Changing WordPress Trash Settings
  9. Adding FTP/SSH Constants
  10. Allow Automatic Database Repair
  11. Increase The PHP Memory Limit
  12. Moving wp-content Directory
  13. Use Custom User Tables
  14. Enable Multi-Site Network
  15. Securing The Configuration File

1. Basic Settings

If you’re working as a WordPress developer, then you must be knowing that there are some Things To Do Before Launching A WordPress Website. One of those things is to know the basic configuration settings.

When you’re installing the WordPress on your system for the first time, then they will surely be asked to fill the database settings as shown in the screenshot below.

Here, if you don’t have the wp-config.php file present, then you will be asked to create one by filling the database details. Generally, WordPress will automatically save these settings by generating a wp-config.php file.

However, if this doesn’t work out, then you need to add this file manually. For that purpose, establish a connection with your website using FTP client or cPanel. Once you’re connected, you need to rename the wp-config sample.php file to wp-config.php file.

Once this task is completed, then you can edit the newly created wp-config.php file. You need to add the database information to this file by adding the following code.

define('DB_NAME', 'database-name');
define('DB_USER', 'database-username');
define('DB_PASSWORD', 'database-password');
define('DB_HOST', 'localhost');

In the end, don’t forget to save the changes & uploading the file back to the server.

2. Adding Security Keys

If you’re working as a developer in a WordPress Development Company for a long time, then you must be knowing that the default WordPress installation comes with security keys which are added to your configuration file.

These keys will add an extra layer to the WordPress login as well as cookies which are used by the website.

However, sometimes there is a situation where you need regenerate the security keys. For that purpose, you should move to wp-config.php file and add the following code which will log out all the logged in users and help you to secure your system.

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. Changing WordPress Table Prefix

When you install the WordPress on your system, the default WordPress Table Prefix will be wp_. However, many industry experts believe that you should change your WordPress database prefix in order to make your site secure.

For that purpose, you need to add the following line of code in the wp-config.php file

$table_prefix = 'wp_';

Now, if you’re doing this for an existing WordPress website, then remember to change the table prefix in your WordPress database.

4. Turning On Debugging In WordPress

WordPress comes with a debugging feature which allows the user to see or hide the WordPress errors while you’re in the debug mode. Now, to turn on this mode, add the following rule in your WordPress configuration file.

define( 'WP_DEBUG', true );

In addition to all these, WordPress also allows you to hide the errors on the website and save them in a log instead. For that to happen, you need to add the following lines of code to your WordPress configuration file.

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

The above code will create a debug.log file inside the wp-content folder and store all the debugging errors & notices inside this file.

5. Changing Your Site & WordPress Address

In a general scenario, you can set the WordPress as well as site URLs by moving to Settings > General page from your WordPress Admin Dashboard. However, you may not able to perform this thing, when you don’t have access to the site or you’ve just moved your website.

In this type of situation, if you want to change the site & WordPress URLs, then you need to add the following lines of code in the wp-config.php file.

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

Here, you shouldn’t forget to replace the example.com with your domain name.

6. Overriding File Permissions

WordPress allows you to override the file permissions only if your host has the restrictive permissions for all the user files. Most users don’t need this kind of facility, but it exists for those who need it. To override file permissions, add following lines of code to a wp-config.php file.

define('FS_CHMOD_FILE', 0644);
define('FS_CHMOD_DIR', 0755);

7. Changing Post Revision Settings

WordPress comes with a very powerful feature for post revisions which allows you to undo changes to your posts & pages by reverting back to the previous version as per your need.

You can disable or change post revisions settings with the use of a configuration file.

To change how often WordPress stores an autosave as a revision, add the following line in the wp-config.php file.

define('AUTOSAVE_INTERVAL', 120); // in seconds

Some articles on your website may have any number of revisions depending on how much time you took to write them. If you think that too many revisions are annoying you, you can limit the number of post revisions by adding the following line wp-config.php file.

define('WP_POST_REVISIONS', 10);

Now, for some reason, if you want to disable the post revisions feature altogether, then you should the following line wp-config.php file.

define( 'WP_POST_REVISIONS', false );

8. Changing WordPress Trash Settings

WordPress comes with a feature called Trash which has the same functionality as that of recycle bin. When a user sends any of their posts to trash, then that post will stay in the trash for the next 30 days and after that, WordPress automatically deletes them forever.

You can change this type of behaviour by changing the number of days for which you want the post to remain in the trash.

define( 'EMPTY_TRASH_DAYS', 15 ); // 15 days

If you don’t like this feature, then you can disable it by adding the following line of code in the wp-config.php file.

Know More...

要查看或添加评论,请登录

Harsh Kundariya的更多文章

社区洞察

其他会员也浏览了