Setting up wordpress environment

Setting up environment in wordpress

December 5th, 2020 Shabu James 472 Views 0 Uncategorised58 seconds

In WordPress new function this environment function is added from 5.5. In this tutorial, we can learn how to use this. By default, this wp environment has the following values that are production, local, development, and staging.

The environment needs to be set up in the wp-config.php file. Like the below example in that we have used production you can change according to the environment you are going to set up.

define( 'WP_ENVIRONMENT_TYPE', 'staging' );
How to use it in your plugin or theme ?

Below is the example for using that.

switch ( wp_get_environment_type() ) {
    case 'local':
    case 'development':
        do_nothing();
        break;
      
    case 'staging':
        do_staging_thing();
        break;
      
    case 'production':
    default:
        do_production_thing();
        break;
}

About The Author

Shabu James

Leave Your Thoughts Here...

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy.

Name *
Comment

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy.