Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

Use here as a reference for parent menu structure.
http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/menu.php

Eg.

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' );
}  
share|improve this answer
    
Thanks, helpful as always :-) –  INT Nov 5 '11 at 21:00
    
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 '11 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 '11 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 '11 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 '11 at 12:36
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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