WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
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

WPBeginner» Blog» Themes» How to Add Custom Dashboard Widgets in WordPress

How to Add Custom Dashboard Widgets in WordPress

Last updated on February 4th, 2017 by Editorial Staff
28 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
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 add this code to your theme’s functions.php file or a site-specific plugin.

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="https://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 widget in WordPress

We hope this article helped you learn how to add custom dashboard widget in WordPress. You may also want to see our guide on how to remove unnecessary items from WordPress admin area.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

28 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

44 Comments

Leave a Reply
  1. Syed Ali Ahmed says:
    Feb 1, 2021 at 3:54 am

    Thanks for sharing this, This is too awesome I love it.

    Reply
    • WPBeginner Support says:
      Feb 2, 2021 at 9:39 am

      Glad you found our guide helpful :)

      Reply
  2. Mike says:
    Jul 21, 2020 at 8:27 pm

    Is it possible to style the widget with custom attributes via HTML or CSS?

    Reply
    • WPBeginner Support says:
      Jul 23, 2020 at 10:07 am

      You could but that is a bit beyond what we cover in our articles.

      Reply
  3. daan van middendorp says:
    Jul 25, 2019 at 6:04 am

    How can I use this for with a custom role ?

    Reply
    • WPBeginner Support says:
      Jul 25, 2019 at 11:12 am

      If your custom role can see dashboard widgets, it should be able to see the custom widget.

      Reply
  4. haqem says:
    Nov 23, 2017 at 10:10 am

    how to put this custom widget at “Add New Post” area for writing

    Reply
  5. Ron Sierra says:
    Oct 24, 2017 at 1:58 pm

    This was asked once but I could not find the reply or answer. How do I create multiple dashboard widgets?

    Reply
  6. Bjornen says:
    Oct 19, 2017 at 6:02 am

    How do I add wp_mail function to this widget?
    Meaning; how do I provide the customer with a contact form in that widget?

    Reply
  7. Vishah says:
    Aug 2, 2017 at 7:06 am

    How can I add a button ?

    Reply
  8. Wade says:
    Mar 2, 2017 at 7:26 pm

    Used your code and got the white screen of death. WP 4.7.2

    Any ideas?

    Reply
    • WPBeginner Support says:
      Mar 3, 2017 at 5:05 pm

      Hey Wade,

      You can remove the code using FTP. Also please see our guide on how to fix white screen of death in WordPress

      Reply
  9. gobinda das says:
    Jan 13, 2017 at 11:46 pm

    can i change the heading Flowtown theme to something else

    Reply
  10. Javier says:
    May 25, 2016 at 6:01 pm

    Hi, I’m trying to create custom widgets on a per user basis. Each user needs to have a widget with different text in it.

    Is there any way to achieve this?

    Reply
    • David Guerreiro says:
      Sep 20, 2016 at 1:04 pm

      That is very easy ! With PHP get the current user on the function that you are using for displaying the metabox content and change the HTML depending of the user retreived. Have a look on this :

      Reply
  11. Lại Đình Cường says:
    Aug 28, 2014 at 8:24 am

    Hello Syed Balkhi, how can I add new admin widget with order?

    Reply
  12. shakun says:
    May 10, 2014 at 4:10 am

    How to add multiple widget on dashboard

    Reply
  13. Nishant says:
    Mar 23, 2014 at 11:55 am

    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

    Reply
    • Dustin says:
      Mar 12, 2017 at 3:13 pm

      This would be great to know. I am also trying to use a shortcode in a dashboard widget.

      Reply
  14. Mike says:
    Feb 7, 2013 at 1:19 pm

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

    Reply
  15. smayzes says:
    Dec 18, 2011 at 4:09 am

    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!’;

    }

    Reply
    • Nick Powers says:
      Nov 25, 2012 at 11:33 pm

      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.

      Reply
  16. luxsub says:
    Sep 16, 2011 at 11:11 pm

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

    Reply
  17. y3kgeek says:
    Jul 6, 2011 at 6:10 pm

    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?

    Reply
    • Editorial Staff says:
      Jul 7, 2011 at 4:10 am

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

      Reply
    • DramaKing says:
      May 22, 2014 at 3:25 pm

      I know it’s been three years, but if others happen to come around here looking for an answer (like me), this is how I did it. I don’t know a lot about coding so it’s probably not clean, but this is how I managed to get it to work:

      add_action(‘wp_dashboard_setup’, ‘dashboard_widget_mail’);

      function dashboard_widget_mail() {
      global $wp_meta_boxes;

      if ( current_user_can( ‘delete_users’ ) ) {

      wp_add_dashboard_widget(‘custom_mail_widget’, ‘Widgetname to show up on dashboard’, ‘custom_dashboard_mail’);
      } return true;
      }

      function custom_dashboard_mail() {

      echo ‘Your custom text here.’;
      }

      —

      You can replace ‘delete_users’ for any capability you like of course.

      Reply
  18. Martin says:
    Mar 30, 2011 at 12:49 pm

    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?

    Reply
    • Editorial Staff says:
      Mar 31, 2011 at 7:04 am

      Yes you would have to add two separate functions and actions…

      Reply
  19. ACS04 says:
    Feb 20, 2011 at 6:41 am

    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 ?

    Reply
    • Editorial Staff says:
      Feb 22, 2011 at 2:17 pm

      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.

      Reply
  20. Frankie Jarrett says:
    Dec 21, 2010 at 12:49 pm

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

    Reply
  21. Stéphane says:
    Jul 26, 2010 at 7:44 pm

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

    Reply
  22. Daniel says:
    Jun 29, 2010 at 4:46 am

    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. :)

    Reply
  23. richard says:
    Mar 28, 2010 at 9:00 pm

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

    Reply
    • Editorial Staff says:
      Mar 29, 2010 at 8:54 am

      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.

      Reply
    • Ash Blue says:
      Mar 29, 2010 at 10:21 am

      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).

      Reply
  24. david says:
    Mar 15, 2010 at 6:24 pm

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

    Reply
    • Editorial Staff says:
      Mar 15, 2010 at 6:36 pm

      You actually include this in your themes functions.php file not the core file.

      Reply
      • cho says:
        Jun 22, 2010 at 12:35 pm

        what do u mean themes function.php?

        i cannot find such a file

        Reply
        • Editorial Staff says:
          Jun 22, 2010 at 7:26 pm

          There is a functions.php file located in your theme’s folder.

  25. Ash Blue says:
    Feb 22, 2010 at 12:14 pm

    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',
    ));
    }

    Reply
    • Editorial Staff says:
      Feb 22, 2010 at 6:01 pm

      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.

      Reply
  26. Vivek @ InfoEduTech says:
    Feb 12, 2010 at 1:46 pm

    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.

    Reply
  27. Jim says:
    Feb 12, 2010 at 11:51 am

    This is awesome thank you for sharing.

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
All in One SEO
Improve website SEO rankings with AIOSEO plugin. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
IPVanish Coupon
Get 20% OFF on IPVanish, one of the best VPN service providers for bloggers and WordPress users.
Theme Trust
ThemeTrust Coupon
Get 20% off on all ThemeTrust themes brought to you by Henry Jones.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.