• Resolved Fixdemonium

    (@problemizer)


    I found this code regarding adding a menu to the admin bar.

    add_action( 'admin_bar_menu', 'admin_bar_item', 500 );
    function admin_bar_item ( WP_Admin_Bar $admin_bar ) {
        if ( ! current_user_can( 'manage_options' ) ) {
            return;
        }
        $admin_bar->add_menu( array(
            'id'    => 'menu-id',
            'parent' => null,
            'group'  => null,
            'title' => 'Menu Title', //you can use img tag with image link. it will show the image icon Instead of the title.
            'href'  => admin_url('admin.php?page=custom-page'),
            'meta' => [
                'title' => __( 'Menu Title', 'textdomain' ), //This title will show on hover
            ]
        ) );
    }

    I am making a simple plugin where I would like to add HTML in the admin bar in place of the menu as shown in the example above. Two simple inputs I need to be displayed in the admin bar to be precise.

    Can someone tell me how this can be achieved?

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to add HTML into admin bar?’ is closed to new replies.