Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Spoygg/a3c210e2b065c5a191cd17d960ccdcb4 to your computer and use it in GitHub Desktop.
Save Spoygg/a3c210e2b065c5a191cd17d960ccdcb4 to your computer and use it in GitHub Desktop.
Add a custom widget to your WordPress dashboard.
// Add a new widget to the dashboard using a custom function
function wpmudev_add_dashboard_widgets() {
wp_add_dashboard_widget(
'wpmudev_dashboard_widget', // Widget slug
'My Custom Dashboard Widget', // Widget title
'wpmudev_new_dashboard_widget_function' // Function name to display the widget
);
}
// Register the new dashboard widget with the 'wp_dashboard_setup' action
add_action( 'wp_dashboard_setup', 'wpmudev_add_dashboard_widgets' );
// Initialize the function to output the contents of your new dashboard widget
function wpmudev_new_dashboard_widget_function() {
echo "Hello from WPMU DEV. The world is your oyster and I'm the pearl! Edit me with HTML or PHP to create the widget of your dreams. ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment