WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've managed to add my own menu to the admin bar. I want the first menu item to link to my theme's options page.

For example, is this 100% bulletproof or is there a direct method?

echo '<a href="'.get_admin_url().'admin.php?page=functions.php">Theme Options</a>';
share|improve this question
up vote 2 down vote accepted

Assuming the installation will never have a plugin register a page with that same name it should be safe, i'd suggest giving your registered page a uniquely prefixed name, and secondly if the page name refers to your theme's functions file wouldn't it then be calling the file directly(you shouldn't ever be calling the theme functions file directly).

You can actually pass get_admin_url and also admin_url the path to append, to use it like this..

echo get_admin_url( null, 'admin.php?page=functions.php' );

or similarly..

admin_url( 'admin.php?page=functions.php' );

No need for concatenation, and of course add the link html back as appropriate(left that out for brevity).

Another suggestion would be to not use the file name as the page value you registered, i keep seeing plugin's do it, and it's always driven me nuts, it makes more sense to just pass the page registration code a unique string, and not a filename(usually done using __FILE__ which i personally find ugly and hacky).

That would be my initial observations, ideally i'd like to see the code that registers the page and know where that registration code sits, ie. what file.

share|improve this answer

How about this:

echo "<a href='".admin_url('/admin.php?page=functions.php)."'>Theme Options</a>";

Codex for admin_url. Btw, are you adding a menu/submenu page for your custom theme options? You can use its slug here.

share|improve this answer

Your Answer


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.