In a clients site i needed to add a menu item under the dashboard, this link is to go to a external url. i managed this with the following code:

add_dashboard_page( 'redirecting', 'Docs', 'read', 'docs', 'redirect_docs');

function redirect_docs(){
    wp_redirect( URL_HERE ); 

This worked fine upto now. My client has now asked me to make the link open in a new tab/window and not change the current page.

Is this possible? If so any suggestions how?

Thanks Sofia xXx

1 Answer 1


That menu is rendered by a function called _wp_menu_output in menu-header.php and I don't see a hook that will let you alter the HTML for those links, which is what you'd need to do-- ie. <a target="_blank" ...

That being as it is you will probably need to do this with Javascript either by rewriting the markup to have the target attribute or by intercepting the click and opening a window.

No matter what you do, though, the browser wins. The user can undo your efforts with browsers settings and/or browser extensions.

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.