Add Menu in WordPress Admin

I’m trying to add a top level menu to the left sidebar of the WordPress admin panel.

Here’s the code I currently have:

Read More
add_action( 'admin_menu', 'linked_url' );
function linked_url() {
add_menu_page( 'linked_url', 'Menu Title', 'read', 'my_slug', '', 'dashicons-text', 1 );
}

add_action( 'admin_menu' , 'linkedurl_function' );
function linkedurl_function() {
global $menu;
$menu[1][2] = "https://www.example.com";
}

This code DOES work and links the menu to an external page (https://www.example.com).

I learned how to do this from here: http://www.techedg.com/2014/09/06/5575/a-simple-way-to-add-an-external-link-to-the-wordpress-admin-menu/

However, I can’t figure out how to make the external link open in a new tab. I’d prefer than a new tab/window is opened so people don’t lose what they already have open in their admin area.

Is there something I need to change or add? Or is it just not possible?

Related posts

1 comment

  1. Did you try:

    add_action( 'admin_menu' , 'linkedurl_function' );
    function linkedurl_function() {
    global $menu;
    $menu[1][2] = "https://www.example.com target="_blank";
    }
    

    So then the opening and closing ” (double quotation) tags are already there, and we only need an attribute added, hence we do that by adding to the current string, while escaping the opening double quotation.

Comments are closed.