# Environment Name in the Browser Tab Title

> Prefixes browser tab titles with [LOCAL], [DEV] or [STAGING] for logged-in users on non-production sites, in the admin and on the front end, so open tabs are easy to tell apart.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: environment, staging, titles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/env-browser-tab-prefix/

## Code

```php
$wpide_env_label = function () {
    $labels      = array( 'local' => 'LOCAL', 'development' => 'DEV', 'staging' => 'STAGING' );
    $environment = wp_get_environment_type();

    return isset( $labels[ $environment ] ) && is_user_logged_in() ? '[' . $labels[ $environment ] . '] ' : '';
};

add_filter( 'admin_title', function ( $title ) use ( $wpide_env_label ) {
    return $wpide_env_label() . $title;
}, 99 );

add_filter( 'document_title_parts', function ( $parts ) use ( $wpide_env_label ) {
    if ( $wpide_env_label() && isset( $parts['title'] ) ) {
        $parts['title'] = $wpide_env_label() . $parts['title'];
    }
    return $parts;
}, 99 );
```

## Notes

Visitors and the production site see normal titles.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Environment Name in the Browser Tab Title" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
