Skip to content
wp-skills
Register
tools/dashboard-widget-generator

WordPress Dashboard Widget Generator

WordPress Dashboard Widget Generator is a tool that allows users to create customizable and interactive widgets in WordPress dashboards.

Runs on wp_dashboard_setup and registers the widget. This is not the function that draws it.

The callback that prints the widget's contents. It echoes; nothing it returns is used.

The heading on the widget's box.

Becomes the box's HTML id, and the key a user's dashboard layout remembers this widget by. Changing it later resets everyone's placement.

Registers it at 'high' priority, which is the argument wp_add_dashboard_widget() gained in WordPress 5.6. A user can still drag it elsewhere.

snippet.php
// Add a custom dashboard widget
function add_custom_dashboard_widgets() {
	wp_add_dashboard_widget(
		'my_custom_widget',
		'My Custom Widget',
		'dashboard_widget_function'
	);
}
add_action( 'wp_dashboard_setup', 'add_custom_dashboard_widgets' );

function dashboard_widget_function() {
	// Display whatever you want to show.
	echo '<p>Hi WordPress, I am a custom dashboard widget from wp-skills.com</p>';
}