do_action( ‘wp_dashboard_setup’ )

Fires after core widgets for the admin dashboard have been registered.

More Information

This hook grants access to Dashboard-related customization options. In particular, this hook is used for adding [wp_add_dashboard_widget()] or removing[remove_meta_box()] dashboard widgets from WordPress.

To add a dashboard widget, use wp_add_dashboard_widget()

To remove a dashboard widget, use remove_meta_box()

Source

do_action( 'wp_dashboard_setup' );

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

  1. Skip to note 4 content

    To remove a dashboard widget, call remove_meta_box() within the hooked function.

    add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
    
    function remove_dashboard_widgets () {
    
          //Completely remove various dashboard widgets (remember they can also be HIDDEN from admin)
          remove_meta_box( 'dashboard_quick_press',   'dashboard', 'side' );      //Quick Press widget
          remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );      //Recent Drafts
          remove_meta_box( 'dashboard_primary',       'dashboard', 'side' );      //WordPress.com Blog
          remove_meta_box( 'dashboard_secondary',     'dashboard', 'side' );      //Other WordPress News
          remove_meta_box( 'dashboard_incoming_links','dashboard', 'normal' );    //Incoming Links
          remove_meta_box( 'dashboard_plugins',       'dashboard', 'normal' );    //Plugins
    
    }
  2. Skip to note 5 content

    To remove all Dashboard widgets:

    function remove_dashboard_widgets(){
        
        global $wp_meta_boxes;
        
        foreach( $wp_meta_boxes["dashboard"] as $position => $core ){
            
            foreach( $core["core"] as $widget_id => $widget_info ){
                
                remove_meta_box( $widget_id, 'dashboard', $position );
            }
        }
        
    }
    add_action( 'wp_dashboard_setup', 'remove_dashboard_widgets', 1000000 );
  3. Skip to note 6 content

    Example from Codex: To Remove a Dashboard Widget

    To remove a dashboard widget, call remove_meta_box() within the hooked function.

    add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
    
    function remove_dashboard_widgets () {
    
          //Completely remove various dashboard widgets (remember they can also be HIDDEN from admin)
          remove_meta_box( 'dashboard_quick_press',   'dashboard', 'side' );      //Quick Press widget
          remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );      //Recent Drafts
          remove_meta_box( 'dashboard_primary',       'dashboard', 'side' );      //WordPress.com Blog
          remove_meta_box( 'dashboard_secondary',     'dashboard', 'side' );      //Other WordPress News
          remove_meta_box( 'dashboard_incoming_links','dashboard', 'normal' );    //Incoming Links
          remove_meta_box( 'dashboard_plugins',       'dashboard', 'normal' );    //Plugins
    
    }

You must log in before being able to contribute a note or feedback.