How to Remove WordPress Dashboard Widgets (also from screen options)

If you login to your wordpress admin area ,you will see some useful (or maybe useless) dashboard widgets. It is a useful feature in single author blogs. By default,you can  turn off any dashboard widget using the “Screen Options” tab at the right top of the admin area. In multi-author blogs it leak some important details to other users. Example:incoming links,recent coments, right now, recent drafts etc.

To completely remove wordpress dashboard widgets (Dashboard quickpress widget,incoming links widget,Recent comments widget,Right Now widget,Dashboard Plugins widget,Dashboard Recent Drafts widget,Dashboard primary widget,Dashboard secoundary widget)

Always Backup Before You Change Anything

Add the below code inbetween the <?php  ?> tag in your dashboard.php file.Example:

<?php your code here ?>

replace “your code here” with the below code. Default path for dashboard.php file

wp-admin/includes/dashboard.php
// Create the function to use in the action hook

function example_remove_dashboard_widgets() {
// Globalize the metaboxes array, this holds all the widgets for wp-admin

global $wp_meta_boxes;

// Remove the Dashboard quickpress widget

unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);

// Remove the Dashboard  incoming links widget

unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);

// Remove the Dashboard Recent comments widget

unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);

// Remove the Dashboard Right Now widget

unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);

// Remove the Dashboard Plugins widget

unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);

// Remove the Dashboard Recent Drafts widget

unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);

// Remove the Dashboard primary widget

unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);

// Remove the Dashboard secoundary widget

unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

}

// Hook into the 'wp_dashboard_setup' action to register our function

add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

Result

Also Read:  How to Improve WordPress Speed Using Performance Lab

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Leave a Reply