Devnote

Web Development Blog Company, Services India

MySQL Error 121 Duplicate key on write - Practical Repair Strategy
MySQL Error 121 Duplicate key on write – Practical Repair Strategy
February 13, 2026
PHP cURL error 60: SSL certificate problem - Windows & Linux Fix
PHP cURL error 60: SSL certificate problem – Windows & Linux Fix
February 11, 2026
Fix localhost refused to connect After Installing XAMPP / WAMP
Fix “localhost refused to connect” After Installing XAMPP / WAMP
February 9, 2026
Composer Error Memory exhausted When Installing Packages - Real Fix
Composer Error: Memory exhausted When Installing Packages – Real Fix
February 6, 2026
MySQL 8 Error Unknown collation: utf8mb4_0900_ai_ci - Safe Migration Guide
MySQL 8 Error Unknown collation: utf8mb4_0900_ai_ci – Safe Migration Guide
February 4, 2026
Devnote

Type and hit Enter to search

  • Home
  • Laravel
    • Auth
    • Migration
    • DATATABLE
    • Yajra
  • wordpress
    • plugin
    • WPBakery
    • woocommerce
  • PHP
    • MYSQL
    • Ajax
  • Blog
  • Informational
    • About us
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
  • Contact US
Devnote
  • Home
  • Laravel
    • Auth
    • Migration
    • DATATABLE
    • Yajra
  • wordpress
    • plugin
    • WPBakery
    • woocommerce
  • PHP
    • MYSQL
    • Ajax
  • Blog
  • Informational
    • About us
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
  • Contact US
How to Add Admin Toolbar Menu link

How to Add Admin Toolbar Menu link

Image
Devnote team
February 19, 2020
2
1K Views
0 Comments

The WordPress admin toolbar is a useful navigation element that appears at the top of the admin dashboard and front-end for logged-in users. If you want to add your own custom shortcuts or menu items for quick access, you can do it directly through your theme’s functions.php file — no plugin required.

In this tutorial, we will use the admin_bar_menu action hook to add a custom top-level menu and dropdown submenu items to the toolbar.

Step-by-Step: Add Custom Toolbar Items

  1. Open your theme’s functions.php file.
  2. Paste the code below.
  3. Replace menu titles, links, or icons with your own values.

Here is a working example:

add_action('admin_bar_menu', 'add_toolbar_items', 100);

function add_toolbar_items($admin_bar){
    $menu_id = 'top-menu-create';

    // Main parent toolbar item
    $admin_bar->add_menu( array(
        'id'    => $menu_id,
        'title' => '<span class="ab-icon dashicons-before dashicons-admin-generic"></span> Barfia setting',
        'href'  => get_admin_url().'admin.php?page=barfia-setting',
        'meta'  => array(
            'title' => __('Barfia setting'),
        ),
    ));

    // Submenu item 1
    $admin_bar->add_menu(array(
        'parent' => $menu_id,
        'title'  => __('Testing'),
        'id'     => 'dwb-drafts',
        'href'   => 'edit.php'
    ));

    // Submenu item 2
    $admin_bar->add_menu(array(
        'parent' => $menu_id,
        'title'  => __('Testing Comments'),
        'id'     => 'dwb-pending',
        'href'   => 'edit-comments.php'
    ));
}

How the Code Works

  • add_action(‘admin_bar_menu’, …)
    Hooks into the WordPress admin bar before rendering.
  • add_menu()
    Adds new menu items to the toolbar.
  • $menu_id
    Used to connect submenu items to their parent item.
  • dashicons
    Displays an icon in the toolbar. You can change it to any Dashicons icon.

Example:

dashicons-admin-home
dashicons-admin-users
dashicons-welcome-view-site

You can find more icons in the WordPress Dashicons library.


Tips

✔ Only logged-in users with the right capability will see the toolbar.
✔ To show menu items only for admins, wrap items with:

if ( current_user_can('manage_options') ) {
    // add toolbar items
}

✔ Never edit core WordPress files — use functions.php or a custom plugin.

Categories:

wordpress

Other Articles

wordpress css feeds
Previous

Create a Custom RSS Feed in WordPress

create a wpbakery visual composer add on
Next

Create A WPBakery Visual Composer Add-On

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

WordPress Critical Error When Editing with Gutenberg - Root Cause + Fix

WordPress Critical Error When Editing with Gutenberg – Root Cause + Fix

February 2, 2026
Solve Elementor stuck on loading After Update - Permanent Solution

Solve Elementor stuck on loading After Update – Permanent Solution

January 23, 2026
WordPress wp-cron.php Not Running on cPanel - Real Fix Without Plugins

WordPress wp-cron.php Not Running on cPanel – Real Fix Without Plugins

January 21, 2026
Fix Cloudflare ERR_TOO_MANY_REDIRECTS After Forcing HTTPS in Laravel or WordPress

Fix Cloudflare ERR_TOO_MANY_REDIRECTS After Forcing HTTPS in Laravel or WordPress

January 9, 2026
Devnote

Devnote provides a collection of tutorials about PHP, Laravel, WordPress, Django, MySQL, Bootstrap, Jquery, Ajax, APIs, CRUD operations, etc.

Devnote © , All Rights Reserved.

Page Links

  • Home
  • About us
  • Blog
  • Contact US
  • Site map

Category

  • PHP
  • Laravel
  • wordpress
  • HTML
  • jQuery

Follow Us

Facebook Instagram Twitter Youtube Linkedin Pinterest
Morbi, Gujarat, India - 363641
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT
Advertisement