WordPress PHP Free

WordPress: Add a Custom Dashboard Widget

Add your own widget to the WordPress dashboard — show today's orders, a checklist, or quick links for your team.

21 lines · Updated Nov 26, 2026

Preview of WordPress: Add a Custom Dashboard Widget
wordpress-custom-dashboard-widget.php
<?php

// Add to your theme's functions.php or a code-snippets plugin.
add_action('wp_dashboard_setup', 'my_custom_dashboard_widget');

function my_custom_dashboard_widget() {
    wp_add_dashboard_widget(
        'my_site_widget',          // widget id
        'My Site — Quick Links',   // title
        'my_site_widget_content'   // callback
    );
}

function my_site_widget_content() {
    echo '<ul>';
    echo '<li><a href="' . admin_url('post-new.php') . '">Write a new post</a></li>';
    echo '<li><a href="' . admin_url('edit.php') . '">All posts</a></li>';
    echo '<li><a href="' . admin_url('upload.php') . '">Media library</a></li>';
    echo '</ul>';
    echo '<p>Today: ' . date_i18n(get_option('date_format')) . '</p>';
}

About this snippet

The WordPress dashboard is the first screen clients see after logging in, and it is usually full of widgets they never use. A custom dashboard widget lets you put something useful there instead: support contact details, quick links, a short guide, or key numbers like today's orders. This snippet registers your own widget with the WordPress Dashboard Widgets API.

How it works

  1. It hooks into wp_dashboard_setup, the action WordPress runs when building the dashboard.
  2. It registers a widget with an ID, a title and a callback function.
  3. The callback prints the widget's HTML — any content you want.

How to use it

  • Add it to a custom plugin for client sites, so it survives theme changes.
  • Escape any dynamic values with functions like esc_html() and esc_url().
  • Show sensitive widgets only to the right users by checking capabilities, e.g. current_user_can('manage_options').

Widget ideas

  • Client support box: your name, email, WhatsApp and a "request a change" link.
  • Quick links: "Add product", "View orders", "Edit homepage".
  • Site stats: published posts, pending comments, today's WooCommerce orders.
  • How-to notes: short instructions for tasks clients repeat.

Tidy up the dashboard

You can also remove default widgets you do not need with remove_meta_box() on the same hook, leaving a clean, branded dashboard.

Common problems

  • Widget not visible: it may be hidden under Screen Options, or placed in a column below other widgets.
  • Slow dashboard: cache expensive queries with transients.

Related: Custom login page logo · Log 404 errors

How to install

Add the code to your theme's functions.php or a code-snippets plugin. Change the title, links and content to show what your team needs — for example today's order count from WooCommerce.

Share this snippet

See all
Chat with us