Add a custom dashboard widget to WordPress

This code snippet allows you to add a custom dashboard widget to WordPress.

PHP

function custom_dashboard_widget() {
    wp_add_dashboard_widget( 'custom_dashboard_widget', 'Custom Dashboard Widget', 'custom_dashboard_widget_function' );
}
add_action( 'wp_dashboard_setup', 'custom_dashboard_widget' );

function custom_dashboard_widget_function() {
  // custom dashboard widget function code goes here
 $widget_content = '<h3>I am a new dashboard widget</h3><p>Customize me!</p>';
 return $widget_content;
}

Snippet Feedback

Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.

10 Views

Tags

Language

Did it work?

Save Snippet

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.