Adding a custom widget in wordpress wp-admin dashboard

Author - Mamta Sharma

How to add a custom widget in wordpress wp-admin dashboard? In following screenshot those boxes in red need to show custom widgets. How to accomplish it:

For adding the custom widget in wordpress admin you have to add this code in your plugin’s main file:

add_action('wp_dashboard_setup', custom_wordpress_widget);
function custom_wordpress_widget()
wp_add_dashboard_widget(‘custom_wordpress_widget’, 'Custom WordPress Widget', 'custom_widget_dashboard_view');
function 'custom_widget_dashboard_view'()
echo “This is custom widget inside wordpress wp-admin dashboard!”;

This will add a custom widget in the dashboard.

This function does all the magic:

wp_add_dashboard_widget(custom_wordpress_widget, 'Custom WordPress Widget', 'custom_widget_dashboard_view');

Syntax of wp_add_dashboard_widget() function is:
wp_add_dashboard_widget( string $widget_id, string $widget_name,callable $callback, callable $control_callback = null,array $callback_args = null );

Where Parameters are:

(string) (Required) Widget ID (used in the ‘id’ attribute for the widget).

(string) (Required) Title of the widget:

(callable) (Required) Function that fills the widget with the desired content. The function should echo its output:

(callable) (Optional) Function that outputs controls for the widget:

(array) (Optional) Data that should be set as the $args property of the widget array

After the installation of your plugin you can see a widget in your WordPress wp-admin dashboard with a title you provided in your code.

I have given it a name “Custom WordPress Widget”, you can see this in below screenshot:

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published.