Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Add Custom Dashboard Widgets in WordPress

Last updated on by
Elegant Themes
How to Add Custom Dashboard Widgets in WordPress

There are tons of new themes coming out for WordPress every day, but none of them seems to utilize this feature. WordPress developers should add custom dashboard widget with support information. In this article we will show you how you can customize dashboard widgets in WordPress.

Simply open your functions.php file and add the following code:

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 Blog Theme! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>. For WordPress Tutorials visit: <a href="http://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';
}

Remember to change the email and add other useful information.

This code can be very helpful when creating custom themes for clients.

Result:

Custom Dashboard Widgets in WordPress

Source: Jake Goldman’s Article at Smashing Magazine


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Nishant says:

    i tried to insert a do_shortcode() with shortcode for a contact form to give user a quick access to report any bug of provide feedback but it doesn’t work … any idea how to get CF 7 working with this ?

    Thanks

  2. Mike says:

    This isn’t working for me in 3.5. Are there any updates to get this working? Thanks!

  3. smayzes says:

    Is it possible to do this using OOP?

    e.g.:

    inside a class:

    wp_add_dashboard_widget(‘custom_help_widget’, ‘Help and Support’, array($this, ‘customDashboardHelp’));

    function customDashboardHelp() {

    echo ‘<p>Welcome to your custom CMS!’;

    }

    • Nick Powers says:

      I know your message is quite old, but for the sake of others who come here and have the same question. Yes, it does work with OOP, just as you have indicated.

  4. luxsub says:

    Is it possible to put a widget with adsense in your dashboard for a multi user site?

  5. y3kgeek says:

    Great idea. What if I want to create a custom dashboard widget that only people with a certain user role, say Contributing Writer, can see?

    • Editorial Staff says:

      You can do this by using the conditional statement if user_can or even user roles.

  6. Martin says:

    Thx for this! It works great.

    Just a quick question:
    If I want to add 2 or more custom widgets in the functions.php, do I have to change the “action” and “function” name?

  7. ACS04 says:

    Sounds good, but should be better to create a simple plugin to do so, in such a way, this widget will be independant from the themes… Don’t you think ?

    • Editorial Staff says:

      Well you can, but in our case it contains support information that we want our clients to know. This is mostly for custom theme designs, so it is only good to have when our theme is activated.

  8. Frankie Jarrett says:

    Thanks a lot for the easy example. I was able to get something up and running in just a few seconds :)

  9. Stéphane says:

    Wow! Never heard about that trick before… Very nice, thanks!

  10. Daniel says:

    Worked like a charm. Using this as a workaround for one of my membership site that locked all dashboard menus; this will point members to the appropriate edit posts links again. :)

  11. richard says:

    when making two widgets how do you make them side by side instead of one on top one on bottom?

    • Editorial Staff says:

      Hey Richard, You can make your widget be displayed at the very top using the code in WordPress Codex Dashboard API. We don’t know how to set them side by side without manually going in and saving it for the client. Perhaps sending an email to Jake and asking him would be a good idea.

      Although remember, the settings you set in functions.php does not override the normal settings if the user has previously changed the settings. This only works if the user never organized his/her dashboard before.

    • Ash Blue says:

      Use display block on the outer most element and float left, make sure to set a width, but that may break it. This is very similar to a gallery layout. This is not suggested and not necessarily how WordPress designed widgets to be used (use at your own risk).

  12. david says:

    wpmu. I have found /wp-includes/functions.php but where should I insert the code? Thanks for your help

  13. Ash Blue says:

    Interesting, I did all of that with the line below. Is one better, or are these both just as good?


    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'name'=>'Contact',
    ));
    }

    • Editorial Staff says:

      Your code is for registering Sidebar Widgets. The code we are sharing in this article is to add custom dashboard widget. When one log in to their wp-admin, they see post stats, and other information. This box will be added there.

      Two completely different topics.

  14. Vivek @ InfoEduTech says:

    thanks for the tutorial.
    please don’t take it wrong whenever you are going to post any article post it with the appropriate screen shot so that it will be easy for the newbie.

  15. Jim says:

    This is awesome thank you for sharing.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.