Find out in this tutorial how to add a custom link into the WordPress administration bar using code.
In a previous tutorial you learned how to hide elements of the WordPress Admin Bar.
But not only can you remove the items you don’t need, you can also add the ones you want to keep on hand. Sounds good, doesn’t it?
In this tutorial you will learn how to add a custom item or link to the admin bar.
Here you go:
Snippet to add a custom menu item to the WordPress admin bar
Add the following code snippet to your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
Thanks to this code fragment, a direct link will be added to the plugins page.
I don’t know about you, but I spend all day in my local test environment adding, activating and deactivating plugins, so it’s great to have this shortcut.
Of course, as always, you can modify the snippet to your liking. You only have to customize the following elements of the array:
- id > menu item identifier (required)
- title > the text to be displayed in the administration bar
- href > the link where you will go when you click
Now you can add that link that you consider essential to have it always close. 😉
Conclusions
Want to add a custom link to the WordPress Admin Bar? Now you know how.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂