Detect a WP Engine Website with PHP

If your workflow includes writing code outside of a WP Engine website and you need a way to tell if a website is hosted on WP Engine, or if you need to differentiate between a WP Engine live website and a legacy staging website through code, we have a function included as part of the WP Engine mu-plugin to help.

This function will tell you if a website is on a WP Engine server, and that it is not a legacy staging site: is_wpe()

  • Returns true 1 only if you are on the “live” WP Engine site (i.e. it is a WP Engine “live” website, and it is not Legacy staging).
    • In terms of this function, “live” also includes Production, Development, and Staging environments.
  • The output of this function is numeric. 1 == true and 0 == false.
  • A boolean value is incorrect, meaning is_wpe()===true will always return false.
  • This function will not determine if an environment is Production, Development or Staging in a “Site” workflow, as these new environments will all simply return is_wpe()===1 or true. To determine an Environment name or Environment by type (Prod, Dev, Stage), try the WP Engine API.

This function will tell you if you are on a WP Engine server and the website is legacy staging: is_wpe_snapshot()


When to Use is_wpe() Function

If you are developing on a local environment and you want to test whether the site you’re seeing is on WP Engine or not, you can use the following to create a testfile.php file in the root directory of your website:

<?php
# Use WordPress functions outside of WordPress files
define('WP_USE_THEMES', false);
global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
require('wp-load.php');
# Ensure the function exists before running it and printing out the return value.
if (function_exists('is_wpe')) {
 echo is_wpe();
} else {
 echo "The function does not exist";
}

Visiting yourdomain.com/testfile.php will then print one of the following:

  • 1 if the site is running on a WP Engine live environment
  • 0 if it is not running on a WP Engine live environment
  • The function does not exist if the is_wpe() function has not been defined in your environment (this should never be the case on a WP Engine server as long as the WP Engine mu-plugin is installed).

NEXT STEP: PHP version and upgrade guide

Still need help? Contact support!

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to your account to get expert one-on-one help.

The best in WordPress hosting.

See why more customers prefer WP Engine over the competition.