# Jetpack Offline Mode on Staging Sites

> Switches Jetpack to offline (development) mode automatically on staging, dev and local hosts, so test copies never connect to WordPress.com or clash with the live site.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: jetpack, staging, development
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/jetpack-offline-mode-staging/

## Code

```php
$wpide_markers = array( 'staging', 'stage.', 'dev.', 'localhost' ); // Host fragments that mean "not live".

add_filter( 'jetpack_offline_mode', function ( $offline ) use ( $wpide_markers ) {
    $host = (string) wp_parse_url( home_url(), PHP_URL_HOST );

    if ( preg_match( '/\.(local|test)$/', $host ) ) {
        return true;
    }

    foreach ( $wpide_markers as $marker ) {
        if ( false !== strpos( $host, $marker ) ) {
            return true;
        }
    }

    return $offline;
} );
```

## Notes

Edit $wpide_markers to match your staging hostnames; .local and .test hosts are always included.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Jetpack Offline Mode on Staging Sites" 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/
