How to Add a Staging Environment Indicator in WordPress

How to Add a Staging Environment Indicator in WordPress

If you work with a staging site, you’ve probably done it: edited a page, saved it, then realised you were on the live site, not the copy. Or worse, deleted something on production that you meant to delete on staging. The two dashboards look identical. A WordPress environment indicator fixes this with a clear, coloured label in the admin bar, such as “STAGING” in orange or “LIVE” in red, so you always know where you are.

In this guide, you’ll learn how WordPress identifies environments, how to add a visible indicator with a plugin or code, and the other settings that should differ between staging and live.

How WordPress Knows Which Environment It’s In

Since WordPress 5.5, every site has an environment type, set with a constant in wp-config.php:

define( 'WP_ENVIRONMENT_TYPE', 'staging' );

There are four allowed values:

Value Use it for
local A copy running on your own computer
development A shared development server
staging A copy used for testing before going live
production The live site (the default if nothing is set)

Plugins and themes can read this value with wp_get_environment_type(), for example to switch off live payments or analytics on staging. But WordPress doesn’t show it anywhere on screen, which is why you need an indicator.

How to Add an Environment Indicator With a Plugin

Environment Status from Simpli Plugin is a free, lightweight plugin that shows a clear environment label in the WordPress admin bar and dashboard, so every team member can see at a glance whether they’re on local, staging or the live site.

  1. Download the plugin ZIP from its product page.
  2. Go to Plugins → Add New Plugin → Upload Plugin.
  3. Upload the file, click Install Now, then Activate Plugin.
  4. Set WP_ENVIRONMENT_TYPE correctly in each site’s wp-config.php.
  5. Check the admin bar on both sites to confirm each shows the right label.

Install the plugin on every copy of the site, including production. A “LIVE” label is the one that saves you from the most expensive mistakes.

Running many client sites across local, staging and live? Simpli Plugin’s team builds custom deployment and workflow tools for WordPress agencies.

Talk to Our Developers →

How to Add an Environment Indicator With Code

Developers can add a simple label to the admin bar with a few lines. This example shows the environment name on every non-production site:

add_action( 'admin_bar_menu', function ( $bar ) {
    $env = wp_get_environment_type();

    if ( 'production' === $env ) {
        return;
    }

    $bar->add_node( array(
        'id'    => 'environment-indicator',
        'title' => strtoupper( $env ),
    ) );
}, 1 );

Add it through a small custom plugin. To make the label stand out, style the #wp-admin-bar-environment-indicator element with a bright background colour in an admin stylesheet.

Other Settings That Should Differ on Staging

An indicator tells you where you are. These settings stop staging from causing real-world problems:

  • Hide staging from search engines. Tick Discourage search engines from indexing this site under Settings → Reading, and ideally protect staging with a password.
  • Stop real emails. Staging copies can send order and password emails to real customers. Use a mail-catching plugin or disable outgoing mail.
  • Use test payment keys. Switch payment gateways to sandbox or test mode.
  • Turn off analytics and pixels so test visits don’t pollute your data.
  • Pause scheduled jobs such as automated newsletters or stock syncs.

Common Problems and How to Fix Them

The Live Site Says “Staging”

The wp-config.php file was copied from staging during a migration. Set WP_ENVIRONMENT_TYPE to production on the live site, or remove the line.

No Label Appears

Check that the admin bar is enabled for your user under Users → Profile, and that the plugin is active on that copy of the site.

The Constant Has No Effect

Make sure the line sits above the comment that says “That’s all, stop editing!” in wp-config.php.

Frequently Asked Questions

What is the default environment type in WordPress?

production. If you don’t set the constant, WordPress assumes it’s a live site.

Do visitors see the environment label?

No. It only appears in the admin bar and dashboard for logged-in users.

Does my host set the environment type for me?

Some managed hosts set it automatically on staging copies. Check wp-config.php to be sure.

Always Know Which Site You’re Editing

A visible environment label is one of the cheapest safety measures in WordPress. Set the environment type on every copy, show it in the admin bar and lock down staging so it can’t email customers or appear in search.

Download Environment Status for free, and browse the full Simpli Plugin library. If you need custom workflow tools, our developers can build them.

Request a Custom Plugin →