# Search Box for the Admin Menu

> Adds a small filter box at the top of the admin menu that hides every menu and submenu item not matching what you type, handy on sites with dozens of plugin menus.

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

## Code

```php
add_action( 'admin_footer', function () {
    ?>
    <style>
    #wpide-menu-filter{margin:8px 10px;width:calc(100% - 20px);box-sizing:border-box;min-height:28px}
    .folded #wpide-menu-filter{display:none}
    #adminmenu li.wpide-hide{display:none}
    #adminmenu.wpide-filtering .wp-submenu{position:static!important;display:block!important;box-shadow:none!important;margin:0!important}
    </style>
    <script>
    ( function () {
        var menu = document.getElementById( 'adminmenu' );
        if ( ! menu ) { return; }
        var input = document.createElement( 'input' );
        input.type = 'search';
        input.id = 'wpide-menu-filter';
        input.placeholder = 'Filter menu...';
        input.setAttribute( 'aria-label', 'Filter admin menu' );
        menu.parentNode.insertBefore( input, menu );

        input.addEventListener( 'input', function () {
            var term = input.value.trim().toLowerCase();
            menu.classList.toggle( 'wpide-filtering', term !== '' );
            menu.querySelectorAll( ':scope > li.menu-top' ).forEach( function ( item ) {
                var top = ( item.querySelector( '.wp-menu-name' ) || item ).textContent.toLowerCase();
                var subs = item.querySelectorAll( '.wp-submenu li:not(.wp-submenu-head)' );
                var anySub = false;
                subs.forEach( function ( sub ) {
                    var match = term === '' || top.indexOf( term ) !== -1 || sub.textContent.toLowerCase().indexOf( term ) !== -1;
                    sub.classList.toggle( 'wpide-hide', ! match );
                    anySub = anySub || ( match && term !== '' );
                } );
                item.classList.toggle( 'wpide-hide', term !== '' && top.indexOf( term ) === -1 && ! anySub );
            } );
            menu.querySelectorAll( ':scope > li.wp-menu-separator' ).forEach( function ( sep ) { sep.classList.toggle( 'wpide-hide', term !== '' ); } );
        } );
        input.addEventListener( 'keydown', function ( event ) {
            if ( event.key === 'Escape' ) { input.value = ''; input.dispatchEvent( new Event( 'input' ) ); }
        } );
    } )();
    </script>
    <?php
} );
```

## Notes

Press Escape to clear the filter; the box is hidden while the menu is collapsed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Search Box for the Admin Menu" 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/
