Skip to content

Environment Type

WordPress 5.5 introduced the WP_ENVIRONMENT_TYPE constant, allowing you to specify the current environment for your site. This helps developers and administrators distinguish between local, development, staging, and production environments, enabling environment-specific configurations and behaviors.

  • Environment Awareness: Easily identify which environment your site is running in (e.g., local, staging, production).
  • Conditional Logic: Enable or disable features, plugins, or code based on the environment type.
  • Improved Safety: Prevent accidental changes or deployments to production by restricting actions in non-production environments.

WordPress recognizes the following values for WP_ENVIRONMENT_TYPE:

  • local
  • development
  • staging
  • production
  1. Open your site’s wp-config.php file (located in the WordPress root directory).
  2. Add the following line above the comment /* That's all, stop editing! Happy publishing. */:
    define( 'WP_ENVIRONMENT_TYPE', 'environment_type' );
  3. Replace 'environment_type' with one of the supported values (local, development, staging, production).
  4. Save and close the file.

If you use WP-CLI, you can set the environment type with:

Terminal window
wp config set WP_ENVIRONMENT_TYPE 'environment_type'

Replace 'environment_type' with your desired value. Note: This command will only work if WP_ENVIRONMENT_TYPE is not already defined in wp-config.php. If it is, you must edit the file manually.

Many themes and plugins can display the current environment type in the WordPress admin toolbar or dashboard, helping you quickly verify which environment you’re working in.