Codex tools: Log in / create account
Contents |
This function adds a new widgets to the administration dashboard using wordpress Dashboard Widgets API.
<?php wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback ); ?>
Here is a simple dashboard widget:
// Function that output's the contents of the dashboard widget
function dashboard_widget_function() {
echo "Hello World, this id my first Dashboard Widget!";
}
// Function that beeng used in the action hook
function add_dashboard_widgets() {
wp_add_dashboard_widget('dashboard_widget', 'Example Dashboard Widget', 'dashboard_widget_function');
}
// Register the new dashboard widget into the 'wp_dashboard_setup' action
add_action('wp_dashboard_setup', 'add_dashboard_widgets' );
To run the function use this code:
do_action( 'wp_dashboard_setup' );
Since: 2.7.0
wp_add_dashboard_widget() is located in /wp-admin/includes/dashboard.php.