• Resolved Jak

    (@123456jk)


    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);
Viewing 1 replies (of 1 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @123456jk,

    That snippet needs to be saved with code type “PHP” to work correctly.

    WPCode also includes an admin bar snippet generator under wp-admin > Code Snippets > Generator > Admin Bar Menu

Viewing 1 replies (of 1 total)
  • The topic ‘Add Custom Links to WordPress Admin Bar’ is closed to new replies.