Nexcess Logo

Useful WordPress constants for your WordPress site

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
January 11, 2023

WordPress is a Content Management System (CMS) that enables users to create and manage a website or blog.

What is WordPress used for?

WordPress is a flexible platform for hosting various kinds of websites and applications. is a popular choice for small businesses, personal blogs, and general informational websites, while is often used for larger-scale projects such as ecommerce stores and membership websites.

WordPress may require some technical knowledge to get started. But once get used to it, it's easy to use. In addition, WordPress is a great way to create a website or blog.

How does WordPress work?

But the question is, how does WordPress work? WordPress uses some core files, a database, files that you add or install, and an administration area to help manage everything. As part of this "WordPress site management ecosystem," there exist "WordPress constants" that we will describe in this article.

About the WordPress Administration module

The WordPress Admin module — as known as the WordPress Administration module or just wp-admin — is the back-end interface where users can create and edit content, add media, manage plugins and themes, and much more.

In addition, the WordPress Administration area is the nerve center of your website. It's where you can manage everything on it, from content to Google AdSense advertisements and site activity tracking scripts — all in one place!

Your WordPress Admin dashboard is accessed via a web browser, and users can either log in to or download and install the WordPress software on their web server.

Below are the significant categories of functionality included in the WordPress Admin area, which correspond to areas of the user interface:


  • Posts
  • Media
  • Pages
  • Comments
  • Appearance
    • Themes
    • Editor
  • Plugins
  • Users
  • Tools
    • Import/Export
  • Settings

The wp-config.php file explained

The wp-config.php file is a configuration file for WordPress that is used to set up the site's database, user authentication, and other settings. It is one of the most important files in WordPress, so it's essential to keep it protected and backed up. Configuring WordPress to use PHP constants is part of the site administration process.

What is a constant in PHP and WordPress?

Aa constant is an identifier that represents a value which can be defined for your system. As implied by their name, constants must remain constant and cannot change while the PHP/WordPress action or script using them is being executed.

The most useful WordPress constants

This article will show you some useful WordPress constants for your WordPress site. There are dozens of WordPress constants that you can use in your code — and we document the most used ones here.

While most of these are intended for use by developers and advanced users, there are several that are useful for everyone. Documented in the sections below are some of the most useful WordPress constants that a site admin should be aware of.

WordPress constant — DB_CHARSET

In computing, a character set is a specific list of characters. A character encoding assigns numbers to each of these characters. For data to be represented accurately on different platforms, it is important to choose an appropriate character set and encoding.

The DB_CHARSET constant defines the database's character set.

Default value: utf8

define( 'DB_CHARSET', 'utf8' );

WordPress constant — DB_COLLATE

A database collation is a set of rules determining how data is sorted and compared.

Default value: utf8_general_ci

define('DB_COLLATE', 'utf8mb4_unicode_ci');

WordPress constant — DB_HOST

A database host is a computer that stores and manages a database. A database host can be a physical server or a virtual machine. A database host typically runs software that helps manage the database.

Values: IP address, domain, or port

Default value: localhost

define( 'DB_HOST', 'localhost' );

WordPress constant — DB_NAME

A database name is a way to identify a particular database. The author can choose any name they want for their database. But it can be helpful to choose a name that is meaningful to users and will help distinguish the database from other databases. Additionally, the author may consider using a name that reflects the purpose of the database.

Value: database name

define( 'DB_NAME', 'MyDatabaseName' );

WordPress constant — DB_PASSWORD

The system uses a database password to connect to its database. The password is stored as clear text in a system property file. Your passwords can be encrypted using either OBSCURED or ENCRYPTED.

define( 'DB_PASSWORD', 'password_here' );

WordPress constant — DB_USER

The database name (DB_NAME) is the name of the database. The username (DB_USER) is the name of the person who is connected to the database.

Value: username

define( 'DB_USER', 'username_here' );

WordPress constant — WP_MAX_MEMORY_LIMIT

WP_MAX_MEMORY_LIMIT is a WordPress constant that allows you to change the maximum memory limit for some WordPress functions.

Default value: 256M

define( 'WP_MAX_MEMORY_LIMIT', '256M');

WordPress constant — WP_MEMORY_LIMIT

WP_MEMORY_LIMIT is the limit for memory WordPress uses.

Default value: 32M

define( 'WP_MEMORY_LIMIT', '256M' );

WordPress constant — TABLE_PREFIX

The $table_prefix is the name you give to your database tables. This prefix is different from the blog's URL. You can change it if you want to use another character string as the prefix rather than wp_ for your tables.

You will do this if you install multiple WordPress blogs on one database, which can be done with the multisite feature:

$table_prefix = 'mynexcess_'; // Only numbers, letters, underscores.

WordPress constant — BLOG ADDRESS (URL) via WP_HOME

WP_HOME is a setting in WordPress that tells people what address to type into their browser to find your blog. The website address should include "HTTP://" or "HTTPS://." If you do not have a slash at the end, it will make fewer calls to the database when people visit your website.:

define( 'WP_HOME', '' );


WP_ALLOW_MULTISITE is a feature that enables multiple sites on one WordPress installation. If this setting is absent from wp-config.php, it will be set to false:

define( 'WP_ALLOW_MULTISITE', true );


The WP_CACHE setting, if set to true, will include the wp-content/advanced-cache.php script when running the wp-settings.php file:

define( 'WP_CACHE', true );

WordPress constant — WP_DEBUG

WP_DEBUG is a popular constant of WordPress. This one is used to display bugs and warnings which helps site owners, developers, and designers to get to the bottom of any error on a website.

This WordPress constant is used to enable debugging mode on your WordPress site. When enabled, WordPress will display warnings and errors on your site, which can be helpful when troubleshooting issues.

Values: true | false

To enable debugging:

define( 'WP_DEBUG', true );

To disable debugging:

define( 'WP_DEBUG', false );

WordPress constant — WP_DEBUG_LOG

Debugging is a process that helps identify and solve problems with a computer program. For example, the WordPress debug log is a file that records all the activity that happens on your WordPress site. The debug log can help you troubleshoot any errors that may occur.

Default value: false

To enable debugging log:

define( 'WP_DEBUG_LOG', true );

WordPress constant — WP_DEBUG_DISPLAY

This one is a debugging tool that lets you see any errors that are happening on your website. When this is turned on, any errors will be shown on your website's front end so you can troubleshoot them.

Turning off this constant will prevent errors from printing on your website in HTML form. You should use WP_DEBUG_DISPLAY along with WP_DEBUG_LOG.

WP_DEBUG_DISPLAY Default Value: true

To disable debugging:

define( 'WP_DEBUG_LOG', false );

WordPress constant — ABSPATH

This constant is useful when you need to include specific files or when you need to create links to certain pages on your site.

For example, if you wanted to include a file from your theme directory, you would use:

ABSPATH. '/themes/my-theme/my-file.php'

This syntax above would point to the file my-file.php in the '/themes/mytheme directory.

Alternatively, if you wanted to create a link to the homepage of your site, you would use

ABSPATH. '/index.php'

This syntax above would point to the home page of your WordPress site.

WordPress constant — AUTOSAVE_INTERVAL

AUTOSAVE_INTERVAL is a setting that controls how often your work is automatically saved.

Default values: 60 seconds

define('AUTOSAVE_INTERVAL', 60);

WordPress constant — WP_PLUGIN_DIR

WP_PLUGIN_DIR is a constant that you put in to find where your WordPress plugins are.

define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );

WordPress constant — EMPTY_TRASH_DAYS

This constant determines how often the trash will be emptied automatically. The default setting is 30 days, but you can change this to any number of days between 1 and 999.

To change the EMPTY_TRASH_DAYS setting, add this to the wp-config.php file:

define('EMPTY_TRASH_DAYS', 35); //35 == days

Keep in mind that changing this setting will not affect any posts or pages already in the trash.

WordPress constant — SAVEQUERIES

WordPress has a few built-in tools to help you optimize your website's performance. One of these is the SAVEQUERIES feature.

This constant allows you to save all of the SQL queries that are run on your website. This feature can be helpful in two ways.

  1. First, it can help you to identify slow queries so that you can optimize them.
  2. Second, it can help you to troubleshoot database issues.

To activate the SAVEQUERIES feature, add the following line to your wp-config.php file:

define('SAVEQUERIES', true);

Once the feature is activated, all of your website's SQL queries will be logged in the WordPress database.

WordPress constant — IMAGE_EDIT_OVERWRITE

IMAGE_EDIT_OVERWRITE lets WordPress replace a picture after you have edited it or keep a copy of the edited image.

Values: true | false

define( 'IMAGE_EDIT_OVERWRITE', true );

WordPress constant — MEDIA_TRASH

If you want to delete media from your WordPress website, you can do so by deactivating the Media Trash function.

To reactivate it, just go to the Settings menu and find the Media Trash option.

Values: true | false

Default value: false

define( 'MEDIA_TRASH', true );

WordPress constant — WP_DEFAULT_THEME

WP_DEFAULT_THEME is a setting that defines the default theme for new WordPress websites. If the theme is not working, WP_DEFAULT_THEME will be used as a fallback.

Value: theme name

Default value: twentytwentytwo

define( 'WP_DEFAULT_THEME', 'twentytwentytwo' );

WordPress constant — WP_IMPORTING

This constant is defined to import data in WordPress.

Value: true

define('WP_IMPORTING', true);

WordPress constant — FTP_SSH

Use this constant to either activate or deactivate SSH.

Values: true | false

define( 'FTP_SSH', false );

WordPress constant — FTP_SSL

Use this constant to either activate or deactivate SSL.

Values: true | false

define( 'FTP_SSL', false );

WordPress constant — FTP_USER

FTP_USER is the username for FTP.

Value: username

define( 'FTP_USER', 'username' );

WordPress constant — FORCE_SSL_ADMIN

FORCE_SSL_ADMIN will activate SSL for logins and in the back end.

Values: true | false

Default value: false

define( 'FORCE_SSL_ADMIN', true );

WordPress constant — FORCE_SSL_LOGIN

FORCE_SSL_LOGIN forces your login process to use SSL.

Values: true | false

Default value: false

define( 'FORCE_SSL_ADMIN', true );

WordPress constant — ENFORCE_GZIP

Gzip can reduce the size of your website's files by a lot. You can turn on Gzip compression by setting the ENFORCE_GZIP constant to true.

When this is turned on, all the website's files will be compressed with Gzip before they are sent to the client. If you don't turn this on, WordPress will use deflated compression instead.

Values: true | false

define('ENFORCE_GZIP', true);

WordPress constant — WP_ALLOW_REPAIR

If you want WordPress to optimize and repair the database, you must set the WP_ALLOW_REPAIR constant to true.

Values: true | false

define ('WP_ALLOW_REPAIR', true);

Once this is done, go to the following URL:

You will see an option to Repair and Optimize the database. Remember to remove the WP_ALLOW_REPAIR constant from wp-config.php once you have completed these tasks.

Consider Nexcess as your hosting provider of choice

If you are looking for a hosting provider that can take your WordPress site to the next level, consider Nexcess We specialize in Managed WordPress hosting and take care of all the complex technical details so you can focus on creating content and engaging with your audience. Our team of experts is available around the clock to provide support and ensure your site is always up and running.

Go with a proven leader in web hosting

Nexcess raises the bar. WordPress hosting with instant autoscaling, visual compare, feature-rich plugins, performance tools, automatic plugin updates, plus free staging.

In addition, our managed hosting plans come with several features designed to improve performance and security, including daily backups, malware scanning, and DDoS atacck protection. With Nexcess, you can be confident that your WordPress site is in good hands.

Contact us today to discuss our services with an expect and get started.

Recent articles

Related articles

Masood Khan
Masood Khan

Masood is a Technical Support Engineer at The Events Calendar. He enjoys solving problems and learning new technologies. He believes in being kind and helpful. He lives by the motto "Be a rainbow in someone else's cloud."

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.