1

I am wondering if I can change the URL of the "Home"-button in the dashboard's admin-bar.

enter image description here

Right now it just redirects to /, but I need it to redirect to /velkommen.

Whenever a logged-in user lands on /, they are already redirected to /velkommen, so in a way it's already working as I want (with an extra redirect), but it would be nice to prevent having to run that javascript redirect, also because it creates waiting time for the user.

I tried the following things, to now luck:

Change homepage url

How to change the Admin-bar's link target?

1 Answer 1

4

Try this. Even if you want to change "View Site" link then remove "site-name" and add "view-site" in get_node. Thanks.

 add_action( 'admin_bar_menu', 'customize_my_wp_admin_bar', 80 );
 function customize_my_wp_admin_bar( $wp_admin_bar ) {
        $site_node = $wp_admin_bar->get_node('site-name');

        //Change link
        $site_node->href = home_url().'/velkommen';

        //Update Node.
        $wp_admin_bar->add_node($site_node);

 }
2
  • Awesome, it worked! Shaved a few ms off of our customer's flow :)
    – Rvervuurt
    Aug 8, 2017 at 13:04
  • @Rvervuurt awesome! enjoy. Aug 8, 2017 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.