How to Add Links to My Sites Sub-Menus in admin bar

Shortlink:

Hi today i will tech you how to add link in sub menus on your WordPress Websites admin bar.

Add Links to My Sites Sub-Menus: Log Out, Media, Links, Pages,
Appearance, Plugins, Users, Tools and Settings
This example expands the My Sites menu.

input this code in your functions.php file on your theme folder.

/*
* Add Links to My Sites Sub-Menus: Log Out, Media, Links, Pages, Appearance, Plugins,
Users, Tools and Settings
*/
function add_mysites_link () {
global $wp_admin_bar;
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
$menu_id = 'blog-' . $blog->userblog_id;
/* Add a Log Out Link */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-logout',
'title' => __( 'Log Out' ),
'href' => get_home_url( $blog->userblog_id, '/wp-login.php?
action=logout' ) )
);
/* Media Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-media',
'title' => __( 'Media Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
upload.php' ) )
);
/* Links Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-links',
'title' => __( 'Links Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/linkmanager.
php' ) )
);
/* Pages Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-pags',
'title' => __( 'Pages Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
edit.php?post_type=page' ) )
);
/* Appearance Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-appearance',
'title' => __( 'Appearance' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
themes.php' ) )
);
/* Plugin Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-plugins',
'title' => __( 'Plugin Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
plugins.php' ) )
);
/* Users Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-users',
'title' => __( 'Users Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
users.php' ) )
);
/* Tools Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-tools',
'title' => __( 'Tools Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
tools.php' ) )
);
/* Settings Admin */
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-settings',
'title' => __( 'Settings Admin' ),
'href' => get_home_url( $blog->userblog_id, '/wp-admin/
options-general.php' ) )
);
}
}
add_action( 'wp_before_admin_bar_render', 'add_mysites_link' );

Tutorial by: Md Abul Bashar
Admin
www.pchelpcenterbd.com
C.E.O

Linux Host Lab | Nursing is our great virtue | Best Domain And Web Hosting service providers.| Domains and Hosting company popular for Bangladeshi, we offer multiple services such as Domain, Web Hosting, VPS, Dedicated Servers, Web Design and Development, SEO etc..

Coding Bank | Beauty And Brains : We Have Both | We’re Provides WordPress Premium Themes, WordPress Free Themes, HTML Free and Premium Themes, Graphic Design, etc..

4 thoughts on “How to Add Links to My Sites Sub-Menus in admin bar”

  1. Paal Joachim Romdahl says:

    Hi

    Thanks for the tutorial on adjusting the multisite My Sites submenu.
    How would one go about changing the name and removing for instance Manage Comments which is an existing link.
    What about hiding all the submenu sections in the drop down?

    Thanks!

  2. Paal Joachim Romdahl says:

    One more thing. You are using wpadmin but it needs to be wp-admin for it to work.

    1. Md Abul Bashar says:

      Thanks for comment, I did updated the code 🙂

      Thanks

  3. Herschel Asakura says:

    Linking your brand page and website helps you connect with your friends, fans, and customers. It also provides Google with information that helps determine the relevancy of your site to a user query on Google Search.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!




%d bloggers like this: