Some WordPress wp_config file Hacks you did not know

by | Aug 24, 2024 | Hacks, WordPress | 0 comments

The wp-config file is a core WordPress configuration file. This file is generated during the WordPress installation and contains details specific to your installation and server environment. 

In this article, we shall look at some hacks and settings that you can effect in your wp_config file. But before we do, be warned that making changes to your wp_config fiel is a critical task and can break your website. Make sure you first back up your website before attempting this. Let’s get started!

How to change MySQL Ports and Sockets in wp_config file

 You can change your MySQL port if your host provider uses other ports for MySQL host. You can change our DB_HOST value to include this port value. You won’t add another line to the file but you will have to edit and existing DB_HOST value to include the alternative one. For instance, if your host provider provides you with the number 3306, you should have something like this:

However, if your web host uses sockes and pipes, a typical edit will look like this:

How to change the URLs in wp_config file

WP_SITEURL is used to define the WordPress address (URL). The  defined value is the location address of your WordPress core files. There will be a time you may have to change your WordPress URLs when moving a WordPress site to a new domain name or a new web host.

When you change the name, this should include the http:// part too. (Do not put a slash “/” at the end.)When you set this value in wp-config.php, it overrides the wp_options table value for siteurl and disables the WordPress address (URL) field in the Settings >> General page of your WordPress dashboard. For instance, assume your domain name is www.yourwebsite.com. You will add the lines below to your wp_config file.

You should note that this modification can be done on your dashboard. Modifying the wp_config file is necessary if you cannot access your dashboard due to some WordPress errors.

Dashboard-General-Settings

How to change uploads directory using the wp_config file

Using the wp_config file, you can change the default storage of your WordPress files. By default WordPress stores your media uploads in the /wp-content/uploads/ directory. This can be changed by specifying the directory in the wp_config file.

How to change the Autosave interval in wp_config file

As you edit your post, WordPress is continuously saving it automatically at specified interval. The default time interval is 60 seconds. WordPress uses Ajax to auto-save your edits. This default time can either be increased to to slow auto-save time period or decreased to make sure you do not lose any changes you make to your post.

How to disable automatic updates in the wp_config file

From WordPress 3.7, automatic update feature was introduced. This allows your WordPress website to automatically update itself when there is even a minor update. This is equally helpful and at times, can be harmful. Automatic updates ensure that the website is kept up to date to avoid any security flaws. However, automatic updates may also break your WordPress website if a code in the updated file conflicts with a plugin or any other code for that mattter. This will make your admin dashboard inaccessible to you. You can disable this in the wp_config file.

How to limit post revisions in wp_config file

You can always revise your post in WordPress. If you are continously revising your website’s posts, your database backup size with inadvertentlly increase. You can however put a lid on the number of revisons allowed. In the line of code below, 9 revisions are allowed for a post. This can be changed to any integer number.

How to disable post revisions in wp_config file

WordPress will always save copies of every edit you will make to a post or page. This allows you to revert to a previous version of that post or page. If you want, you can disable the revision of posts or pages. This is similar to the preceding code but instead of passing an integer, you rather pass the boolean value, false.

How to enable Multisite/Network Ability

In WordPress 3.0, the WP_ALLOW_MULTISITE feature introduced. This enabled a multisite functionality in WordPress. If this feature is absent in the wp_config.php file, the default setting is false.

How to disable JavaScript concatenation

Javascritp files are concatenated  into one URL. This helps in a faster administration area. However, if Javascript is experiencing a hard time running, you may want to disable this feature.