# Warning Banner When Editing Key Pages

> Shows a prominent warning at the top of the editor when someone opens an important page, such as the homepage, checkout or a landing page, reminding them to be careful.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: notices, pages, editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-warning-on-key-pages/

## Code

```php
// Page ID => message.
$wpide_key_pages = array(
    // 123 => 'This page is linked from every email we send. Check links after editing.',
);

$wpide_key_page_message = function () use ( $wpide_key_pages ) {
    $post = get_post();
    if ( ! $post || 'page' !== $post->post_type ) {
        return '';
    }
    $pages = $wpide_key_pages;
    if ( (int) get_option( 'page_on_front' ) ) {
        $pages[ (int) get_option( 'page_on_front' ) ] = $pages[ (int) get_option( 'page_on_front' ) ] ?? 'This is the homepage. Changes are visible to every visitor immediately after updating.';
    }
    if ( (int) get_option( 'wp_page_for_privacy_policy' ) ) {
        $pages[ (int) get_option( 'wp_page_for_privacy_policy' ) ] = $pages[ (int) get_option( 'wp_page_for_privacy_policy' ) ] ?? 'This is the privacy policy. Legal review may be required for changes.';
    }
    return $pages[ $post->ID ] ?? '';
};

// Classic editor.
add_action( 'admin_notices', function () use ( $wpide_key_page_message ) {
    $screen  = get_current_screen();
    $message = $screen && 'post' === $screen->base ? $wpide_key_page_message() : '';
    if ( $message ) {
        printf( '<div class="notice notice-warning"><p><strong>Careful:</strong> %s</p></div>', esc_html( $message ) );
    }
} );

// Block editor.
add_action( 'enqueue_block_editor_assets', function () use ( $wpide_key_page_message ) {
    $message = $wpide_key_page_message();
    if ( ! $message ) {
        return;
    }
    wp_add_inline_script(
        'wp-notices',
        sprintf(
            'wp.domReady(function(){wp.data.dispatch("core/notices").createNotice("warning",%s,{isDismissible:false,id:"wpide-key-page"});});',
            wp_json_encode( 'Careful: ' . $message )
        ),
        'after'
    );
    wp_enqueue_script( 'wp-notices' );
    wp_enqueue_script( 'wp-dom-ready' );
} );
```

## Notes

The homepage and privacy page are included automatically; add more page IDs and messages to $wpide_key_pages.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Warning Banner When Editing Key Pages" 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/
