How to Add Custom Links to the WordPress Admin Toolbar

How to Add Custom Links to the WordPress Admin Toolbar

December 2, 2024

The WordPress admin toolbar is a powerful tool that provides quick access to essential areas of your site. If you frequently navigate to specific pages or want to provide quick links for your team, adding custom links to the admin toolbar can improve efficiency.

In this guide, we’ll walk through how to add custom links to the WordPress admin toolbar using a simple code snippet.

Why Customize the Admin Toolbar?

Adding custom links to the admin toolbar can help:

  • Provide quick access to frequently used pages (e.g., support pages, documentation, or third-party tools).

  • Improve workflow efficiency for admins and editors.

  • Offer easy navigation for custom plugin settings.

Code Snippet: Adding a Custom Link to the Admin Toolbar

To add a custom link to the WordPress admin toolbar, you can use the admin_bar_menu hook. The following snippet adds a new link to the toolbar that points to an external website:

Copy to Clipboard

Explanation of the Code:

  • admin_bar_menu Hook: This hook allows us to modify the admin toolbar.

  • $wp_admin_bar->add_node(): Adds a new link (node) to the toolbar.

  • id: A unique identifier for the toolbar item.

  • title: The text that appears in the toolbar.

  • href: The URL the link points to.

  • meta: Additional properties like opening in a new tab or adding a custom class.

Adding a Submenu Item

If you want to add a submenu under an existing toolbar item, such as under the WordPress logo, use this modified snippet:

Copy to Clipboard

Where to Add This Code

You can add this snippet to your theme’s functions.php file, a custom plugin, or use the Code Snippets plugin for easy management.

Conclusion

Adding custom links to the WordPress admin toolbar is a great way to enhance navigation and workflow efficiency. Whether you’re linking to external resources, frequently used pages, or plugin settings, this customization can save time and make managing WordPress even smoother.

Give it a try!

Leave A Comment

SitesByYogi

Read My Full
WordPress Blog!

Check Out My Full WordPress Blog

Get in-depth tutorials, tips, and insights to master WordPress. Includes expert tips, tutorials, and insights to help you elevate your WordPress skills and website performance.