Add “external” link to admin menu in the backend

Trying to add a link to my admin menu (dashboard/backend) that leads to the frontend of wordpress, so I basically want a link in the menu that takes me to the blog.

I’ve found a couple of ways to add new stuff to the admin menu, but I haven’t been able to link to the home_url, it seems like the admin menu only is designed to let you link to stuff within the wp-admin. Anyone that have succeeded with this?

Read More

Edit:
Tried with this: https://gist.github.com/792b7aa5b695d1092520

add_admin_menu_item('Overview',array( 
      'title' => 'View Site',
      'slug' => get_bloginfo('url')
  ));

Which gives me the link hxxp://myurl.com/myurl.com
With this plugin (hxxp://wordpress.org/extend/plugins/admin-menu-editor/), I get:
hxxp://myurl.com/wp-admin/www.test.com

Related posts

Leave a Reply

5 comments

  1. you can create a function that redirects to the front-end
    like this:

    function redirect_home_987(){
      wp_redirect( home_url() ); 
      exit;
    }
    

    and call that function in WordPress default add_menu_page function like this:

    add_menu_page( 'redirecting', 'View Site', 'read', 'my-top-level-handle', 'redirect_home_987');
    

    Hope this helps

  2. The name of site (top left, next to WP logo) links to front-end, is that not sufficient?

    Also it would help if you included code that you had tried so far in the question.

  3. You cannot add items to the admin menus that point to external URLs, the menu addition functions do not support this, nor will they allow it.

    However, if you attach a callback onto the admin_menu hook, you can insert some items yourself manually and totally overcome the non-external URL problem. I do this myself and i’m quite surprised noone has already pointed out the issue with external menu links.

    I provided an example when answering Adding an Arbitrary Link to the Admin Menu?

    Let me know if that helps.

  4. add_action('admin_menu', 'example_admin_menu');
    
    /**
    * add external link to Tools area
    */
    function example_admin_menu() {
        global $submenu;
        $url = 'http://www.example.com/';
        $submenu['tools.php'][] = array('Example', 'manage_options', $url);
    }