How to Make Changes to the wp-config.php File in WordPress

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 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 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 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 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 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

Open your FileZilla program and access the root folder of WordPress.

open filezilla

NOTE: We have a tutorial to help you set this up if you need it.

Change the local site to a directory on your computer you will use to store a backup copy of the wp-config file. A backup will help you recover should something happen or if the coding turns out to be faulty.

filezilla backup

Drag the file from the root folder of WordPress and into your local saved directory. FileZilla will immediately make the backup copy.

drag the file to the root folder of WordPress

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.

right click file for options

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.

make coding changes

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.

finish edting

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

Log into your cPanel account.

login to cpanel

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.

file manager

Once you are in the website’s root directory, click wp-config once to highlight it.

click wp config

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.”

click download function

After you save a backup copy, click the “Edit” function in the top tool bar.

edit function

A text editor window will open allowing you to select character encoding. Leave this as “utf-8” and click the “Edit” button.

text editor function

Make your coding changes.

make your coding changes

Click the “Save Changes” button on the top right.

click save button top right

Any modifications you make to wp-config 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 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 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:

[ht_message mstyle=”info” title=”” ” show_icon=”” id=”” class=”” style=”” ]

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘yourname_wrdp12’);

/** MySQL database username */
define(‘DB_USER’, ‘yourname_wrdp12’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘7dFkEoEo1F9CD1d’);

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

[/ht_message]

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:

[ht_message mstyle=”info” title=”” ” show_icon=”” id=”” class=”” style=”” ]define(‘DB_HOST’, ‘localhost:1234’);[/ht_message]

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:

[ht_message mstyle=”info” title=”” ” show_icon=”” id=”” class=”” style=”” ]define(‘WP_HOME’,’https://yoursite.com’);
define(‘WP_SITEURL’,’https://yoursite.com’);[/ht_message]

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:

[ht_message mstyle=”info” title=”” ” show_icon=”” id=”” class=”” style=””]define( ‘WP_AUTO_UPDATE_CORE’, false );[/ht_message]

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.

How often do you modify code in your WordPress website? Do you have a favorite code-editing system?

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.