Taking a Closer Look at Wp-config.php File in WordPress

Wp-config file in Wordpress
Share this:

Wp-config.php file is the one of the main file in WordPress. In this article we’ll explore and take a closer look at the wp-config.php file.

Introduction to wp-config.php file 

Advanced Wp-config.php Options

You can set advanced choices in your wp-config file, these choices aren’t within the wp-config file by default, therefore you’ll have to be got to manually add them to the file.

To set your WordPress address and blog address, use the subsequent 2 options:

The WP_SITEURL option permits you to quickly modify the WordPress website URL. This doesn’t alter the database choice value for siteurl, however instead quickly changes the value. If this feature is removed, it reverts back to the database setting.

The WP_HOME choice works in the precise same manner, letting you quickly modify the home value for WordPress. Each values ought to embrace the complete URL including http://.

A choice that enables you to maneuver the wp-content directory. The 2 needed options are:

The WP_CONTENT_DIR choice worth is that the full native path to your wp-content directory. The WP_CONTENT_URL is that the full URI of this directory. Optionally you’ll set the path to your plugins directory like so:

WP_PLUGIN_DIR and WP_PLUGIN_URL are options employed by plugin developers to work out wherever your plugin folder resides. If a plugin developer isn’t using these constants there’s a awfully sensible likelihood their plugin can break if you move your wp-content directory. Never move the wp-content directory on your production server without initial testing during a development setting.

WordPress saves post revisions for every saved edit created to a post or page. Edits are saved by clicking either the Save or Publish button, and additionally by the inherent auto save feature of WordPress. Imagine if every post you produce has ten revisions. If you had a hundred posts, that will be 1,000 records in your database.

This could quickly increase the scale of your database and should even weigh down your website because table records will take longer to fetch in larger databases. As luck would have it WordPress incorporates a inherent post revisions choice known as WP_POST_REVISIONS.

You’ll set this feature to false to fully disable post revisions altogether, otherwise you will specify a most variety of revisions to stay for every post or page.
Following are samples of each scenarios:

You can additionally configure the auto save interval by setting the AUTOSAVE_INTERVAL choice. WordPress uses AJAX once editing a post to auto-save revisions. By default this interval is 60 seconds. You’ll set the interval in seconds for auto save in wp-config. Set auto save to 5 minutes by using this code:

Debugging errors in WordPress is created easier using the WP_DEBUG choice. Enabling WP_DEBUG shows WordPress errors on the screen, instead of suppressing those errors with a white screen. To enable WP_DEBUG simply set the choice worth to true:

If this feature isn’t outlined in wp-config it defaults to false and error messages aren’t displayed.
Remember to disable or take away this feature after you are done debugging as a result of error messages might facilitate hackers notice vulnerabilities in your website.

Another nice debugging choice is SAVEQUERIES. Activating this feature saves all information queries into a global array that may be displayed on your page. This could assist you debug query problems, and additionally to envision exactly what WordPress is executing on every page load.

If you’re engaged on a subject or plugin, and can’t appear to induce the proper set of posts back, this debug option can show you precisely what WordPress is posing for out of the database. Alter this feature by setting the value to true:

To show the query array in your theme, add the subsequent code to any theme model file to view:

The preceding code displays the saved query array given that the logged-in user has the flexibility to put in plugins, primarily locking it down therefore solely website directors can see the output.

You can additionally enable logging directly from your wp-config file. To enable logging, initial you would like to create a php_error.log file and upload it to your root WordPress directory. Then merely activate the log_errors PHP choice and point to your logging file:

All errors can currently be logged to the present file. This can additionally log any errors made by enabling the WP_DEBUG option mentioned earlier. Within the preceding example display_errors is ready to Off, that is ideal for a production website as a result of you don’t need error messages displayed. If you’re debugging and need to view errors in real time, simply set that choice to On.

You can additionally set the memory limit WordPress is allowed to use with the WP_MEMORY_LIMIT choice. If your website hits the memory limit set for WordPress to run, you’ll see the error ‘‘Allowed memory size of xxxxx bytes exhausted.’’ Increasing the memory limit fixes this drawback. The memory limit is set by shaping the megabytes needed:

Setting this feature works given that you’re hosting company permits it. Some hosting corporations won’t allow dynamically changing the memory limit and can have this worth set terribly low. This drawback is usually found on cheaper hosting corporations.

This will increase the memory just for WordPress and not alternative applications running on your server. To increase the memory limit across all of your websites, set the php_value memory_limit variable in your php.ini file. As an example, once importation massive amounts of content, say months or years price of blog posts, it’s possible you’ll hit this memory limit.

One superb feature of WordPress is that the inherent localizer. WordPress displays in English by default, but will simply be set to show any language that has been translated. Setting the WPLANG choice triggers WordPress to load the desired language files:

The option value contains the ISO-639 language code followed by the ISO-3166 country code. So en-GB would be English-Great Britain. This setting can reference your .mo and .po files for language translation.

You can additionally outline the LANGDIR choice. This feature defines what directory can hold your language .mo files. By default WordPress looks in wp-content/languages for the .mo file. If you’d prefer to move this folder simply set the LANGDIR choice like so:

WordPress can currently look within the new location for your .mo files.
CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE are terribly powerful choices. They’re helpful if you want to possess 2 or a lot of individual WordPress installs use constant user accounts. Bear in mind to set this before putting in WordPress.

Setting these 2 choices helps you to outline the name of the default WordPress user and user meta table. Doing this implies each blogs share user data together with usernames, passwords, author bios, and so on. This is often an excellent way to setup a brand new installation of WordPress however not lose syncronization together with your current user base.

If you’d like your users to possess totally different roles on every WordPress install, however still share user accounts, don’t set the CUSTOM_USER_META_TABLE choice. Everything hold on within the user tables can keep the same, however everything else are blog-specific (that is, user level, first and last name, and so on).

You can set multiple cookie choices like COOKIE_DOMAIN, COOKIEPATH, and SITECOOKIEPATH. These options are usually utilized in a WordPress alphabetic character (multi-user) installation utilizing subdomains for blogs.

This allows you to line the first domain therefore cookies is created and valid on all subdomains
in the network.

Typically you won’t have to be compelled to use or modify this feature, however if you run into problems with cookies this is often the first place to examine.

Since the inclusion of the automated installer practicality for plugins and themes, further because the automatic upgrade method, you’ll set FTP settings directly in your wp-config file. This is often solely required if your host isn’t designed to support the automated install method.

This is often simply detectable as a result of each time you are attempting to put in a plugin or theme you’re asked for your FTP data.
To save your FTP data in WordPress add the subsequent choices in your wp-config file:

Just enter your FTP username, password, and host with port and you’re all set! WordPress can no longer ask for your FTP data once using the automated installer.
You can set further FTP/SSH choices for numerous configurations:

You can additionally override default file permissions in WordPress using the FS_CHMOD_FILE and FS_CHMOD_DIR options:

The numeric single digit values represent the User, Group, and World permissions set for files and folders on your web server. To be told a lot of concerning WordPress and file permissions visit:

These settings will facilitate with bound hosting corporations that use restrictive permissions for all user files. This will override the server settings and may enable WordPress upgrades and auto installations to work.

The WP_CACHE choice is needed for a few caching plugins to figure. Enabling this feature can embrace the file wp-content/advanced-cache.php. To alter this feature use the subsequent code:

WordPress incorporates a heap of constant choices that may be set. As luck would have it there’s a PHP perform to look at all constants presently assail your installation:

An advanced choice is forcing SSL on log in to your WordPress website. This needs users to log in via the HTTPS access link and encrypts all information being transferred to and from your website. To activate SSL on login, add the FORCE_SSL_LOGIN choice like so:

You can additionally force all admin pages to run using SSL. This is often activated with the FORCE_SSL_ADMIN option like so:

This forces all admin dashboard pages (/wp-admin) to be encrypted with SSL. Keep in mind that activating this setting slows down your admin page load times, however all information passed to and from WordPress will be encrypted using SSL.

Additionally bear in mind that your website should be designed to work with SSL.
The quick way to take a look at is to go to your website using https, as in https://example.com. If the page hundreds, SSL is set up on your server.

Am I missing something here? Let me know in the comments!

Did you like this guide of Wp-config file in WordPress? Share it with your friends on Facebook, Twitter, and Google Plus!

Don’t forget to Subscribe to our Newsletter for more insightful post updates, tips and guides!

See you in the next post.

Stay awesome!

Authored By Aakanksha Singh

Hi, I’m Aakanksha, a computer science engineer and the founder of TheTechPower. I help people make there online presence process easier by empowering them with clean, beautiful and easy to use wordpress themes.

Share this:

Leave a Reply