Created
March 30, 2016 04:53
-
-
Save hsleonis/67d2a759be9e017ff0d457f69cd03b52 to your computer and use it in GitHub Desktop.
WP add a widget to the dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add a widget to the dashboard. | |
| * | |
| * This function is hooked into the 'wp_dashboard_setup' action below. | |
| * Reference: https://codex.wordpress.org/Dashboard_Widgets_API | |
| */ | |
| function example_add_dashboard_widgets() { | |
| wp_add_dashboard_widget( | |
| 'example_dashboard_widget', // Widget slug. | |
| 'Example Dashboard Widget', // Title. | |
| 'example_dashboard_widget_function' // Display function. | |
| ); | |
| } | |
| add_action( 'wp_dashboard_setup', 'example_add_dashboard_widgets' ); | |
| /** | |
| * Create the function to output the contents of our Dashboard Widget. | |
| */ | |
| function example_dashboard_widget_function() { | |
| // Display whatever it is you want to show. | |
| echo "Hello World, I'm a great Dashboard Widget"; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment