Orange Foxtrot fox illustration for Add Custom Admin Bar Buttons

Add custom buttons to the WordPress admin bar with the admin_bar_menu hook.

Add the following example to your functions.php file and customize the button details for your workflow:

/* Add Admin Bar Button */

add_action('admin_bar_menu', 'add_admin_bar_button', 100);
function add_admin_bar_button($admin_bar){
    $admin_bar->add_menu( array(
        'id'    => 'my-button-id',
        'title' => 'My Button',
        'href'  => 'https://www.mylink.com/',
        'meta'  => array(
            'title' => __('My Button'),
            'target' => '_blank',
        ),
    ));
}
allen

Allen Robinson

Director of Application Development
Allen has been responsible for overseeing client website development, implementation, and maintenance at Foxtrot Media for over 10 years. A Computer Science graduate from the University of Wisconsin- Madison, Robinson is a software development and content management system specialist, fluent in CSS, PHP, MySQL, HTML, and JavaScript.
allen

Allen Robinson

Director of Application Development
Allen has been responsible for overseeing client website development, implementation, and maintenance at Foxtrot Media for over 10 years. A Computer Science graduate from the University of Wisconsin- Madison, Robinson is a software development and content management system specialist, fluent in CSS, PHP, MySQL, HTML, and JavaScript.

Post Details

Categories:

Related Articles