You need a better, faster web host
Free Site Migration, Amazingly Fast, Secure & Eco-Friendly WordPress Hosting with 24/7 Support. Check Out Hosting Plans
WordPress is a great system to use whether you’re a beginner or an advanced user. Making changes in code is just one of the ways this system is customized to give a unique experience for both visitors and site owners. When it comes time to make changes in the core of how WordPress functions, you will more than likely edit the wp-config.php file.
The configuration of the entire core of WordPress is affected by this file. It controls everything from automatic updates to monitoring how many times someone can make revisions of any certain post. As long as you know what you’re doing in PHP, you can make WordPress do just about anything.
Today, I’m going to demonstrate how you can make changes to this file. Be warned, however. Making incorrect changes in code can result in severe problems.
If you don’t know what you’re doing, it’s easy to break the site.
Why make changes to the wp-config.php file?
Although you might be able to find some of the best WordPress plugins for your purposes, sometimes they just don’t exist. In other situations, it may be simply easier to add a snippet of code than to spend time looking for a perfect plugin solution.
One thing a lot of people don’t consider is compatibility. Sure, you might be able to find a plugin to alter the database WordPress uses for the site. Then you need to worry about whether the plugin will be compatible and if the developer will constantly support updates.
Perhaps the biggest reason why people edit the wp-config.php file is to add customization. It’s one of the best ways to create a tool for an exact purpose and not settling on what a plugin offers. You get precisely what you’re looking for as soon as you save. That is, as long as the coding is correct.
Accessing the wp-config.php File for WordPress
If you’ve spent time exploring WordPress, you’ll eventually find the editor tool. This part of the admin panel is good for making adjustments to a theme, but it doesn’t access the wp-config.php file. That’s because it’s a core file that can easily break the site if modified incorrectly.
To access the file, you’ll have to do so directly. This is accomplished by either using FTP programs such as FileZilla or through cPanel using the File Manager.
Using FileZilla to Open wp-config.php
Open your FileZilla program and access the root folder of WordPress.
Change the local site to a directory on your computer you will use to store a backup copy of the wp-config.php file. A backup will help you recover should something happen or if the coding turns out to be faulty.
Drag the file from the root folder of WordPress and into your local saved directory. FileZilla will immediately make the backup copy.
Right-click the file in the root folder and select “Edit” from the options. This will load your default text editing software if you have one. Many Windows users just simply upon Notepad for this.
NOTE: For Mac computers, hold down the command key when clicking the file to bring up options.
Make the coding changes you wish and then save the project. FileZilla will inform you a file has changed.
Click the check box for “Finish editing and delete local file” and click the “Yes” button. This will not delete your backup copy, just the temp file FileZilla uses for editing on your computer.
Once you’re done making your changes, access the website. It’s always good practice to make sure the site works before shutting down FileZilla. If everything is working properly, simply close the program. Otherwise, you can drag your copy back into the WordPress root folder if something in the code didn’t work.
Using File Manager from cPanel to Access wp-config.php
Log into your cPanel account.
Click on the link for “File Manager.” If you’re using an older version of cPanel, a window may open asking which domain you want to access. Select the site you are editing.
Once you are in the website’s root directory, click wp-config.php once to highlight it.
Click the “Download” function from the top tool bar to make a backup copy. Save it somewhere that will be easy to find later if you need it. This can also be done by right-clicking the file and selecting, “Download.”
After you save a backup copy, click the “Edit” function in the top tool bar.
A text editor window will open allowing you to select character encoding. Leave this as “utf-8” and click the “Edit” button.
Make your coding changes.
Click the “Save Changes” button on the top right.
Any modifications you make to wp-config.php in the File Manager will be instantly live. You can then access the site to make sure everything is working. If so, close out of File Manger and exit cPanel.
Simple Things You Can Change
It’s important to note that certain changes in wp-config.php will not affect the site as a whole. For instance, you wouldn’t want to try to change the text font color or size of the posts. This file is for the configuration of the WordPress core. So, you would edit things like databases.
Editing the Database
The first setting in the wp-config.php file is the way WordPress accesses the database. In reality, the only time you would want to make changes to this portion is if you transfer the website or you’re using a backup copy for restoration. Otherwise, changes to the database can cause a variety of issues with the site. For example, your posts will be different or completely gone.
The database is seen as:
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
Note the name, user and password will be different from this example. It’s these lines that you would change for a new database.
Perhaps you need to assign a port to the database. Some hosts provide secure ports to database resources, and you may need to change how WordPress finds them. In this case, you would simply change the “localhost” control like so:
The “1234” will need to be changed to the host’s port they assign to you.
Site Name and Identification
In some instances, you may have to manually change how WordPress defines the website’s URL. This is used when troubleshooting some of the more common errors in WordPress such as the redirecting issue caused by some plugins. This is fixed by adding the code below:
Disabling Auto Update
WordPress is capable of updating itself when minor changes are made. However, many people would rather the system not do so until they are sure the website can handle the changes. To stop the system from updating, add the following:
define( ‘WP_AUTO_UPDATE_CORE’, false );
These are only a few things that are possible in code. It all centers around your specific needs. Just make sure you always have a backup of any file you modify in WordPress. It will save you a lot of aggravation should something not work like it was intended.