Add menu and submenu in admin with a URL instead of slug?

This is an old post but can’t you just use wordpress $menu and/or $submenu globals like Oleg suggested in number 2.

When in doubt copy WordPress:

wordpress/wp-admin/menu.php

For example to add link this seems like it would work:

function add_external_link_admin_submenu() {
    global $submenu;
    $permalink = admin_url( 'edit-tags.php' ).'?taxonomy=category';
    $submenu['options-general.php'][] = array( 'Manage', 'manage_options', $permalink );
}
add_action('admin_menu', 'add_external_link_admin_submenu');

You can replace the $permalink = ... with anything

So this should also work :

$permalink = 'http://www.example.com';

Also, it’s suggested not to use ‘administrator’ (even though I use it as well. Anyway, read this ticket for alternative solutions.

Leave a Comment