# Pause WP-Cron Outside Production

> Stops scheduled tasks from running on local, development and staging copies of the site, so a cloned database does not send newsletters, sync orders or run backups twice.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: cron, staging, environment
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/cron-pause-outside-production/

## Code

```php
add_filter( 'pre_get_ready_cron_jobs', function ( $jobs ) {
    if ( 'production' === wp_get_environment_type() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
        return $jobs;
    }

    return array(); // Nothing is due, so wp-cron.php does nothing.
} );
```

## Notes

It relies on WP_ENVIRONMENT_TYPE in wp-config.php; tasks still run if you trigger them manually with WP-CLI.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Pause WP-Cron Outside Production" 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/
