how to create wordpress dashboard widgets

How to Create WordPress Dashboard Widgets

Wouldn’t it be cool to have your very own custom WordPress dashboard widget- a widget that will be displayed on your Dashboard page upon logging into WordPress?

To get started, add the following contents to the functions.php file in your current theme directory:

Under the above code in the functions.php file, go ahead and add the following:

Lastly, we add the following code to the bottom of the above code:

Once the above code has been added to the current theme’s functions.php file, log in to your WordPress Dashboard and you should see your custom Dashboard widget.

Tip: If you don’t see your dashboard widget, click on “Screen Options” (this option is located at the top right of your WordPress Dashboard area) and make sure you check the box next to your widget’s title.

Now that we can see how easy it is to create a dashboard widget in WordPress- How about a real life example?

The above example will display a widget (in the dashboard) titled ‘Latest Comments’ with the last 10 comments with a status of ‘approved’.

Each comment will have the users name, a link to their website (if specified) and their comment, with a link to the post at the bottom, followed by a horizontal rule.

This widget will display (by default) on the dashboard of any user that is registered on your wordpress install. You can easily take this to the next level, with: http://wordpress.org/extend/plugins/ag-custom-admin/

This is a nice plugin that I have used in the past for customization of the admin area.

Once its all setup you can configure the plugin and one of the options is to customize both admin and user dashboards or just customize the user dashboard.

When chooing the latter, you can then go and create some custom widgets and create a unique dashboard for your registered users.

Keep in mind, that you would then need to be using the functions script from the ag-custom-admin plugin directory- to ensure that the widgets are not displaying globally.

I hope you found this resource useful!

Interested in WordPress Plugin Development?

Wordpress Plugin Development Video Tutorial

At ZENVA we have a comprehensive video course on WordPress Plugin Development, check it out here.

Published by

Ashley Menhennett

Ashley is a web designer + developer, programmer and technical author from Australia.Ashley holds certification in IT + Web Based Technologies and specializes in modern mobile and responsive web design, working with bleeding-edge web based technologies—including HTML5 and CSS3.

Share this article

  • Good tutorial. there are many other plugin are also available that will help you to add custom content on your dashboard.
    to add some simple info you can use functions.php file as well. There are many functions are also available