In this tutorial i will let you know very interesting things with you, which will help you to create custom dashboard widgets in wordpress. If you want to display some information related to your website on your dashboard so that you don’t need to go in other menu option.
If you create a custom wordpress widgets and display that information on that. There are two ways to do this first is you can simply edit your functions.php file and add below snippets at the end of the file.
1 2 3 4 5 6 7 8 9 10 11 |
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets'); function my_custom_dashboard_widgets() { global $wp_meta_boxes; wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help'); } function custom_dashboard_help() { echo '<p>Welcome to Custom WordPress widgets! Need help? Contact the developer <a href="mailto:[email protected]">[email protected]</a>. For More cool WordPress Tips click: <a href="https://www.freewebmentor.com" target="_blank">Cool WordPress Tutorials</a></p>'; } |
If don’t want to add above code in your functions.php file, you can create a custom plugin for that. Lets start to create custom plugin. Go to the wp-contents => Plugins and create a folder named “custom-dashboard-widgets”. create index.php file and add the header information to describe plugin.
Add a valid PHP code with below header comment look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php /* Plugin Name: Custom WordPress Widgets Plugin URI: https://freewebmentor.com/ Description: Custom WordPress widgets Version: 1.0.0 Author: freewebmentor Author URI: https://freewebmentor.com/ License: GPL2 License URI: https://www.gnu.org/licenses/gpl-2.0.html Text Domain: freewebmentor Domain Path: /languages */ |
After the above code add below code, below code will create a custom widget with sample messages.
1 2 3 4 5 6 7 8 9 10 11 |
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets'); function my_custom_dashboard_widgets() { global $wp_meta_boxes; wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help'); } function custom_dashboard_help() { echo '<p>Welcome to Custom WordPress widgets! Need help? Contact the developer <a href="mailto:[email protected]">[email protected]</a>. For More cool WordPress Tips click: <a href="https://www.freewebmentor.com" target="_blank">Cool WordPress Tutorials</a></p>'; } |
After creating plugin login to your website’s admin panel and activate plugin via Plugins menu. Now navigate to the dashboard there you will see the below outputs.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: create custom widget in wordpress, create custom widget wordpress, custom dashboard widgets, custom widgets wordpress, wordpress create a widget, wordpress create custom widget, wordpress custom plugin, wordpress custom widget