Add Custom Links to WordPress Admin Bar

Hi

I was searching to find a way to add a text link (custom link) to the admin toolbar and found and article about the code to be inserted into the WPCode plugin.

The code for this I have taken from your article is shown below.

In the code below I have just replaced “title” with my own title and “href” with the URL I want to link to. I have saved it as HTML. In all Snippets” panel” I have selected “Status” to ON. After that, I checked the admin toolbar, but there is nothing showing up.

Would you please let me know what I have done wrong here? I am a beginner in this field and do not know much about coding!

Many thanks!

// add a link to the WP Toolbar
function wpb_custom_toolbar_link($wp_admin_bar) {
    $args = array(
        'id' => 'wpbeginner',
        'title' => 'Search WPBeginner', 
        'href' => 'https://www.google.com:443/cse/publicurl?cx=014650714884974928014:oga60h37xim', 
        'meta' => array(
            'class' => 'wpbeginner', 
            'title' => 'Search WPBeginner Tutorials'
            )
    );
    $wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'wpb_custom_toolbar_link', 999);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer