Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Creating a Custom Dashboard Widget in WordPress

    In WordPress, Dashboard (wp-admin) is the first screen you see when you log into the administration area of your blog. The WordPress Dashboard allows you to control all of the behind-the-scene details of managing your site. Once you find your way around the dashboard, you’ll realize it’s really easy to use and navigate.

    The Dashboard Screen presents information in blocks called widgets. By default, WordPress delivers five widgets on this page: At a Glance, Activity, Quick Draft, WordPress News, and Welcome.

    In this blog, we will add a Custom Dashboard Widget and show some the posts which are been published.

    So, for doing that we need to follow 3 steps:

    • Registering the dashboard widget in WordPress.
    • Creating a function which handles the content display.
    • Calling a function to display the posts.

    So lets start with the first step :

    STEP 1. Registering dashboard widget in WordPress :

    For registering the dashboard widget we use built in function ‘wp_add_dashboard_widget‘  :

    This function takes 3 parameters :
    • Widget slug
    • Widget title
    • Display function
    This should be called at the the hook :


    STEP 2. Creating a function which handles the content display :

    In this step we will fetch the posts that we will display on our dashboard widget. As the callback option required a valid function to handle the widget’s content, let’s add a function for this named in previous step as ‘wk_dashboard_widget_function‘.

    STEP 3. Calling a function to display the posts :

    The last step include the setting up the posts on the widget. for that we will add the following code :

    After following all the above steps, now when we visit our dashboard we will find a new widget titled as ‘Custom Dashboard Widget’ listing different posts that are been published as shown in below :

    Hope this blog will help you to create your custom dashboard widget in a better way to make the the dashboard area more attractive and you can enhance dashboard widgets by creating some nice styles or applying some Javascript functionality. Try this and if you have any query then just comment below.

    Thanks for reading 🙂


    . . .

    Comments (2)

    Add Your Comment

  • wpdeveloper
    Great article and examples! It saved a lot of time. It is just what I needed.
    • Suraj Kumar
      Hello There,
      Thanks for the appreciation.
      Webkul Team.
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again