(855)-537-2266 sales@kerbco.com

Inside every WordPress site, there’s a special file that can make a big difference: the wp-config.php file. Many people know the basics of this file, but there’s a lot more to it. In this guide, we’ll share some simple and useful tricks that can help your site work better and more safely. If you’re curious about getting the most out of WordPress, keep reading!

Accessing the wp-config.php file: Key points to consider

  1. Locate the File: The wp-config.php file sits in the root directory of your WordPress installation. If you have access to your web server through a File Manager (often found in cPanel) or via an FTP client like FileZilla, navigate to the main directory where WordPress is installed. You should see wp-config.php listed alongside folders like wp-content, wp-admin, and wp-includes.
  2. Backup Before You Begin: Before making any changes, always create a backup of the wp-config.php file. This ensures that you can quickly revert to the original state if anything goes wrong.
  3. Be Cautious: The wp-config.php file is crucial to your WordPress site’s operation. A small error, like an incorrect value, can break your site. Always double-check any changes you make.

1. WP_ALLOW_REPAIR

If you suspect that your database is corrupt, you can define this constant and allow WordPress to repair it automatically like so:

When set, it enables the database repair page that you can access by visiting http://yourwpsite.com/wp-admin/maint/repair.php. Once you are done don’t forget to either remove it or set it to false.

2. AUTOMATIC_UPDATER_DISABLED

define( 'AUTOMATIC_UPDATER_DISABLED', true );

When added, it disables all automatic updates in WordPress. This includes updates for the WordPress core, plugins, themes, and translations. It’s especially useful for website managers who prefer to handle updates manually, ensuring that they have full control over any changes to their site. However, with this setting enabled, it’s essential to regularly check for and apply important updates to keep the site secure and functioning well.

3. WP_AUTO_UPDATE_CORE

To control the WordPress core updates, use this constant:

It can have three values:

  • Value of true – Development, minor, and major updates are all enabled.
  • Value of false – Development, minor, and major updates are all disabled.
  • Value of 'minor' – Minor updates are enabled, development, and major updates are disabled.

4. DISALLOW_FILE_EDIT

For security reasons, you may want to disable the file editor inside the WordPress dashboard. This constant disables the theme and plugin editor. If you’re managing a client’s site and want to ensure that neither the client nor any other users accidentally or intentionally edit the theme or plugin files directly from the WordPress dashboard, you can use this constant:

5. WP_POST_REVISIONS

By default, WordPress stores every version of a post or page as a revision. This can take up a lot of database space. Use this constant to control the number of revisions, in the following example we are setting the number to 5 revisions

or to disable them altogether:

6. EMPTY_TRASH_DAYS

In the day-to-day operation of a WordPress site, content gets created, updated, and, inevitably, deleted. When items (like posts, pages, or comments) are deleted in WordPress, they aren’t immediately and permanently removed. Instead, they move to the Trash, offering a safety net against accidental deletions.

The EMPTY_TRASH_DAYS constant in the wp-config.php file governs how long items remain in the Trash before WordPress permanently deletes them. By default WordPress will empty the trash every 30 days. Let’s say this value to 7 days, 1 week:

I would strongly suggest against setting this constant to zero, especially for sites with multiple authors. Without the trash safety net, accidental deletions are irreversible.

7. AUTOSAVE_INTERVAL

As you write or edit a post, WordPress periodically saves a draft automatically. It’s a valuable safety net, ensuring that in case of a crash, lost connection, or inadvertent tab closure, your hard work isn’t lost. By default, WordPress will autosave your content every 60 seconds but you can customize this by setting this constant:

define('AUTOSAVE_INTERVAL', 120); // 120 seconds, 2 minutes.

8. WP_MEMORY_LIMIT

As your site grows, receives more traffic, or uses more plugins, it might require more memory to operate smoothly. The WP_MEMORY_LIMIT constant allows you to specify the maximum amount of memory that can be consumed by PHP for WordPress processes. You can set a custom value like so:

define('WP_MEMORY_LIMIT', '128M');  // Set PHP memory limit to 128 megabytes.

If you want to learn more about this constant, you can read Jetpack’s excellent guide on how to check and increase your memory limit.

9. CORE_UPGRADE_SKIP_NEW_BUNDLED

When WordPress releases major updates, it often comes with new themes or plugins that are bundled with the core package. These themes, like the annual “Twenty” series (e.g., Twenty Twenty-Three), are automatically added to your site upon updating WordPress. While this ensures users have access to the latest default themes, not every site administrator or developer may want these additional themes installed. The CORE_UPGRADE_SKIP_NEW_BUNDLED constant provides a solution to this:

10. WP_DEFAULT_THEME

If you create multiple WordPress sites for clients, setting a custom default theme ensures a consistent starting point for every new site. By setting this constant, every installation will start with a specific custom theme. Set it like so:

Ensure that the theme specified in WP_DEFAULT_THEME is present in the wp-content/themes/ directory. If the theme isn’t found, WordPress will default to one of the “Twenty” series themes.

11. WP_DEBUG

This constant triggers the “debug” mode throughout WordPress. When set to true, WordPress will start displaying PHP errors, notices, and warnings. It’s an invaluable tool during development to catch potential issues, as these errors can give insights into problematic plugins, themes, or custom code. Keep in mind that WP_DEBUG should typically be set to false on production sites.

12. WP_DEBUG_DISPLAY

This constant controls whether the errors and warnings generated by WP_DEBUG are displayed on the screen. When set to false, these errors will be hidden from users. Combined with WP_DEBUG_LOG (see below), this means errors will be captured in the log but not shown on the site.

13. WP_DEBUG_LOG

When this constant is set to true, any errors that would be displayed on the screen (as controlled by WP_DEBUG and WP_DEBUG_DISPLAY) will be saved to a debug.log file inside the wp-content directory. This provides a way to track errors over time or capture sporadic issues.

Remember, every adjustment to the wp-config.php is a step towards perfecting your site, but always tread with caution. Ensure you back up regularly, and consider every change’s impact.

The post 13 Essential wp-config.php tweaks every WordPress user should know appeared first on CSSIgniter.

This content was originally published here.