# Keep Only Chosen Dashboard Widgets

> Removes every dashboard widget, including those added by plugins, except the ones on your allow list.

- Type: PHP
- Runs: Admin only
- Category: [Dashboard](https://wpide.com/library/category/dashboard/)
- Tags: dashboard, widgets, cleanup
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/keep-only-chosen-dashboard-widgets/

## Code

```php
// Widget IDs to keep. Core IDs: dashboard_right_now, dashboard_activity, dashboard_quick_press, dashboard_site_health, dashboard_primary.
$wpide_keep_widgets = array( 'dashboard_right_now', 'dashboard_activity' );

// Set to true to apply the cleanup to administrators as well.
$wpide_clean_for_admins = false;

add_action( 'wp_dashboard_setup', function () use ( $wpide_keep_widgets, $wpide_clean_for_admins ) {
    global $wp_meta_boxes;

    if ( ( ! $wpide_clean_for_admins && current_user_can( 'manage_options' ) ) || empty( $wp_meta_boxes['dashboard'] ) ) {
        return;
    }

    foreach ( $wp_meta_boxes['dashboard'] as $context => $priorities ) {
        foreach ( $priorities as $priority => $widgets ) {
            foreach ( array_keys( (array) $widgets ) as $widget_id ) {
                if ( ! in_array( $widget_id, $wpide_keep_widgets, true ) && 0 !== strpos( $widget_id, 'wpide_' ) ) {
                    unset( $wp_meta_boxes['dashboard'][ $context ][ $priority ][ $widget_id ] );
                }
            }
        }
    }

    remove_action( 'welcome_panel', 'wp_welcome_panel' );
}, 999 );
```

## Notes

Widgets added by WPIDE snippets (IDs starting with wpide_) are always kept.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Only Chosen Dashboard Widgets" 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/
