How to add a custom link to the WordPress Admin toolbar

Source: Internet
Author: User
Keywords WordPress toolbar

Intermediary transaction SEO diagnosis Taobao guest Cloud host technology Hall

By default, the WordPress toolbar is displayed at the top of the user's Web page, but you can also disable the WordPress Admin toolbar by using the following code:

Add_filter (' Show_admin_bar ', ' Hide_admin_bar ');

However, this toolbar can also be applied in more places, especially if your site is a WordPress site with many authors, in today's WordPress tutorial, we will show you how to add a customized shortcut link to the WordPress toolbar.

When and why do I need to add a custom shortcut to the WordPress toolbar?

By default, the WordPress toolbar displays frequently used links at the top, allowing users to quickly access different parts of their site.

Then everyone has access to other external links, such as other music, pictures, materials, websites, etc., while working or writing articles. These custom shortcut links can be added to the WordPress toolbar so that you or your registered users can quickly access these shortcuts.

Add a custom shortcut link for the WordPress toolbar

To add a custom shortcut link to the WordPress toolbar, you need to simply copy and paste the following code into your subject's functions.php file:

function Custom_toolbar_link ($wp _admin_bar) {$args = array (' ID ' => ' wpmee ', ' title ' => ' WordPress fan ', ' href ' => ' https://www.wpmee.com ', ' meta ' => Array (' class ' => ' Wpmee ', ' title ' => ' access to WordPress fan ')); $WP _admin_bar->add_node ($args); } add_action (' Admin_bar_menu ', ' Custom_toolbar_link ', 999);

The code in the example is a link to the website of the WordPress fan, you can change it to any link you need, such as Baidu Network, shrimp music and so on.

How do I add a set of custom links to a toolbar?

We just showed you how to add a custom link to a toolbar, but if you want to add multiple links, how do you create a set of shortcuts on the toolbar like the WordPress custom menu? In doing so, you can organize multiple shortcut keys under a parent.

//Custom management bar link function custom_toolbar_link ($wp _admin_bar) {$args = array (' ID ' => ' wpmee ', ' title ' => ' WordPress fan ', ' href ' => ' https://www.***.com ', ' meta ' => Array (' class ' => ' Wpmee ', ' title ' => ' access to WordPress fan ')); $WP _admin_bar->add_node ($args); $args = array (' ID ' => ' wpmee-theme ', ' title ' => ' wordpress theme ', ' href ' => ' http://www.***.com/wptheme/', ' parent ' => ' Wpmee ', ' meta ' => Array (' class ' => ' Wpmee-theme ', ' title ' => ' view more wordpress theme ')); $WP _admin_bar->add_node ($args); $args = array (' ID ' => ' wpmee-tutorials ', ' title ' => ' wordpress tutorial ', ' href ' => ' http://www.***.com/wpcourse/', ' PA Rent ' => ' wpmee ', ' meta ' => Array (' class ' => ' wpmee-tutorials ', ' title ' => ' View more wordpress tutorials ')); $WP _admin_bar->add_node ($args); $args = array (' ID ' => ' wpmee-plugins ', ' title ' => ' wordpress plugin ', ' href ' => ' http://www.***.com/plugins/', ' paren T ' => ' wpmee-tutorials ', ' meta ' => Array (' class ' => ' Wpmee-plugins ', ' title ' => ' view more wordpress plugin '); $WP _admin_bar->add_node ($args); } add_action (' Admin_bar_menu ', ' Custom_toolbar_link ', 999);

In the example code, we first added a custom link for the WordPress fan, and then we added a custom link as a child link for the WordPress fan, we add the parameters: ' Parent ' => ' Wpmee ', and then add a same custom link, and finally add a wordpress plugin to the WordPress tutorial below, we use: ' Parent ' => ' wpmee-tutorials ', smart you must understand? There is still no understanding of the place welcome message. Respect others labor achievements, transfer please specify: http://www.wpmee.com, thank you for your cooperation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.