I am creating a plugin for add menu option to WordPress admin and using below function for that:

<?php add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); ?>

But I would like to add absolute path for menu option in the place of $menu_slug.

enter image description here

please see the screen shot, I have created both " Header and footer " using add_menu_page function. I would like to give absolute path for both header and footer. I know plugins are available for this but I am creating my plugin with different functionality.

  • 1
    Could you narrow down absolute path to where? If it's another site entirely then WP probably won't let you without much grief. For same site it depends.
    – Rarst
    Oct 19, 2014 at 17:37
  • Please read my question once again I have update my question.
    – user49799
    Oct 20, 2014 at 6:09
  • But where does those link point to? A file in your theme? Plugin?
    – Rarst
    Oct 20, 2014 at 7:57
  • I would like for plugin
    – user49799
    Oct 20, 2014 at 9:19

1 Answer 1


I don't think there is a clean way to put arbitrary link into the menu item. At most you could change it with JavaScript after the fact.

However there is an edge case that allows you to load plugin file there.

  1. Pass as $menu_slug argument a path to a plugin file relative to plugins directory, for example plugin-folder/boo.php.
  2. Omit $function argument.
  3. This will generate link like admin.php?page=plugin-folder/boo.php.
  4. Following the link will load the file as content of admin page.

There isn't actually much benefit over just using callback for output. But from technical point of view this is about as close as possible to including a file in there.

  • but I want to add third party link there.reay my question I want to put absolute path.not like your given example
    – user49799
    Oct 20, 2014 at 13:24
  • Then you are stuck with JS most likely. I don't quite follow why would Header/Footer send user out of admin entirely, but if that's what you need to do — WP doesn't do it.
    – Rarst
    Oct 20, 2014 at 13:27
  • You can use this method and just redirect to the external URL. Following the example here, inside the plugin-folder/boo.php file include <meta http-equiv="refresh" content="0;url=http://example.com/">. May 15, 2015 at 3:52

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.