# Tuck Admin Notices Into a Collapsible Panel

> Gathers the banners plugins print at the top of admin screens into one "Notices" panel that stays closed until you open it, while errors and your own save messages stay visible.

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

## Code

```php
add_action( 'admin_footer', function () {
    ?>
    <style>
    #wpide-notices-panel{margin:12px 20px 0 2px}
    #wpide-notices-panel summary{cursor:pointer;color:#2271b1;font-weight:600}
    #wpide-notices-panel[open] summary{margin-bottom:8px}
    </style>
    <script>
    ( function () {
        var wrap = document.querySelector( '#wpbody-content .wrap' );
        if ( ! wrap ) { return; }
        var notices = Array.prototype.filter.call(
            document.querySelectorAll( '#wpbody-content > .notice, #wpbody-content > .updated, #wpbody-content > .update-nag, #wpbody-content .wrap > .notice, #wpbody-content .wrap > .updated' ),
            function ( el ) {
                return ! el.classList.contains( 'notice-error' ) && ! el.classList.contains( 'error' ) && ! el.classList.contains( 'notice-success' ) && ! el.classList.contains( 'inline' ) && ! el.id.match( /^(message|setting-error-settings_updated)$/ );
            }
        );
        if ( notices.length < 2 ) { return; }
        var panel = document.createElement( 'details' );
        panel.id = 'wpide-notices-panel';
        var summary = document.createElement( 'summary' );
        summary.textContent = 'Notices (' + notices.length + ')';
        panel.appendChild( summary );
        notices.forEach( function ( el ) { panel.appendChild( el ); } );
        wrap.parentNode.insertBefore( panel, wrap );
    } )();
    </script>
    <?php
} );
```

## Notes

Success messages after saving and notices marked as errors are never hidden.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tuck Admin Notices Into a Collapsible Panel" 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/
