Keep Only Chosen Dashboard Widgets
Removes every dashboard widget, including those added by plugins, except the ones on your allow list.
Opens WPIDE on
Code
// 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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.