I want to create a entirely new top level menu in the admin menu section, and have that be an external link, is this even possible with the current system?

The solution that t31os provides in this thread works if you put the link as a submenu under, for example, the dashboard. But this is not what I want to do.

Adding an Arbitrary Link to the Admin Menu?

2 Answers 2


Just add your custom item into $menu instead of $submenu.

Use here as a reference for parent menu structure.


add_action( 'admin_menu' , 'admin_menu_wpse32975' );
function admin_menu_wpse32975() {
    global $menu;
    $menu[9999] = array( __('My Menu'), 'manage_options', 'http://www.google.com', '', 'open-if-no-js menu-top', '', 'div' );
  • I wanted to use this code for another project, but I just now realized that using this piece of code, I don't get the "current" class when the link is active (like you do on regular admin menu items). I really need this for a coherent styling in this project. Do you have any ideas?
    – INT
    Dec 22, 2011 at 1:04
  • How would that work exactly? Once you click that link you should no longer be on the WordPress site(if the link the points to an external URL).
    – t31os
    Dec 22, 2011 at 8:49
  • Oh, doh. Was a bit tired when I wrote that. I'm now using the code to create a "shortcut" to a dashboard url. It's a direct link to a submenu item: pastebin.com/q89sAVTi
    – INT
    Dec 22, 2011 at 10:15
  • If you're going to point it to an interal page use the proper menu functions, add_menu_page or add_submenu_page and it will deal with marking an item as active/current for you.
    – t31os
    Dec 22, 2011 at 12:36
  • I thought so too, but either I'm doing it wrong or it doesnt work: pastebin.com/PeiFnW6N There's a link but it doesn't show if it's active/current.
    – INT
    Dec 22, 2011 at 16:13

For external link this will work using the add_menu_page or add_submenu_page. Just change http://www.google.com below to your desired link:

function add_custom_menu_item_external_url(){
    add_menu_page( 'My Posts', 'My Posts', 'manage_options', 'link-to-google', 'custom_menu_item_redirect', 'dashicons-admin-links', 1 );
add_action( 'admin_menu', 'add_custom_menu_item_external_url' );

function custom_menu_item_redirect_external_link() {
        $menu_redirect = isset($_GET['page']) ? $_GET['page'] : false;
        if($menu_redirect == 'link-to-google' ) {
            header('Location: http://www.google.com');
add_action( 'admin_init', 'custom_menu_item_redirect_external_link', 1 );

For internal link use below and change home_url() or for something like the logged in author page check that out:

function add_custom_admin_menu_page_home_url(){
    add_menu_page( 'Home', 'Home', 'manage_options', 'home-redirect', 'custom_menu_item_redirect_home_url', 'dashicons-admin-links', 1 );
add_action( 'admin_menu', 'add_custom_admin_menu_page_home_url' );

function custom_menu_item_redirect_home_url() {
        $menu_redirect = isset($_GET['page']) ? $_GET['page'] : false;
        if($menu_redirect == 'home-redirect' ) {
            wp_safe_redirect( home_url() );
add_action( 'admin_init', 'custom_menu_item_redirect_home_url', 1 );

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.