Add a group of links under a parent link in wordpress admin top bar

Home / Internet / Add a group of links under a parent link in wordpress admin top bar

In this article, I will show you how to add custom shortcut links to WordPress toolbar. By default the wordpress admin toolbar shows useful links to WordPress administration screens for quickly access different sections of website.

You can add custom links to WordPress admin top toolbar allowing you and your users easy access to those locations directly from your site or the admin area.

To add a custom shortcut link to the WordPress admin top toolbar, you need to simply copy and paste the following code in your theme’s functions.php file or in a site-specific plugin.

/** add a group of links under a parent link in wordpress admin top bar*/
// Add a parent shortcut link
function custom_toolbar_link($wp_admin_bar) {
$args = array(
'id' => 'home',
'title' => 'Home',
'href' => 'http://www.rimixr.net',
'meta' => array(
'target' => '_blank',
'class' => 'home',
'title' => 'Visit Home'
)
);
$wp_admin_bar->add_node($args);
// Add the first child link
$args = array(
'id' => 'wordpress',
'title' => 'View All WordPress Post',
'href' => 'http://www.rimixr.net/category/wordpress/',
'parent' => 'home',
'meta' => array(
'target' => '_blank',
'class' => 'wordpress',
'title' => 'View All WordPress Post'
)
);
$wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'custom_toolbar_link', 999);
Related Posts