• I was using the below code to remove some/all widgets from the dashboard:

    
    add_action('wp_dashboard_setup', 'wpdocs_remove_dashboard_widgets');
    
    function wpdocs_remove_dashboard_widgets(){
       remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
    }
    

    But I think this is not the best way? Because it actually remove the widgets after WordPress added them.

    Is it possible to tell WordPress that don’t create/generate these widgets at first?
    The wp_dashboard_setup hook fires after core widgets for the admin dashboard have been registered, is there a hook that fire before they are added, and how to stop them?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Dion

    (@diondesigns)

    The only way to keep the default dashboard widgets from being registered is to hack the wp-admin/index.php file. This will in fact keep ALL dashboard widgets from being registered, not just the defaults (which is IMO a good thing).

    Otherwise, you must manually remove the dashboard widgets after they have been registered. It’s not optimal, but it’s far better than the alternative of running bloated, hard-on-server widget code that is mostly useless. (I’m looking at you, WP Events/News!)

    It’s unfortunate the “show boxes” screen option only hides a widget display as opposed to removing the widget. There’s a reason so many people complain about their dashboard page being so slow…and this simple change could solve that issue.

    Thread Starter ace0930

    (@ace0930)

    @diondesigns What is the bloated code you are referring to? Is the below code bloated?

    
    add_action('wp_dashboard_setup', 'wpdocs_remove_dashboard_widgets');
    
    function wpdocs_remove_dashboard_widgets(){
       remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
    }
    
    Dion

    (@diondesigns)

    The bloated code is in wp-admin/includes/cashboard.php. Your code is fine; it’s the safe way to remove a dashboard widget.

    Keep in mind that numerous plugins/themes add dashboard widgets, a good number of which are (IMO) very poorly coded and cause serious server issues. Most should also be removed.

    I wrote a plugin for clients that allows them to selectively remove any/all dashboard widgets and also most notices/pointers/nags. Given how often I am thanked for it, I know I’m not the only one who has a problem with the crapshow otherwise known as the WP dashboard page.

    Thread Starter ace0930

    (@ace0930)

    @diondesigns Genius! But I think it’s hard to remove the notices because they are using include_once inside a function with add_action. The problem is that there are other codes inside that function which causes me cannot just remove that with remove_action because it gonna broke the plugin. I am just afraid it’s not a good idea to change the others’ plugin code directly by another/my plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Best way to remove widgets from the dashboard’ is closed to new replies.