Support » Fixing WordPress » how to get admin url? get_site_url?

  • Resolved Rev. Voodoo


    I have an uploader in my theme that had worked pretty good, however it has a hardcoded path I’d like to work on

    //If no errors registred, redirect back to the theme options panel
    	if(isset($_POST['Submit']) && !$errors)
    	$url = get_bloginfo('url') . '/empire/wp-admin/admin.php?page=functions.php';
    	header ("Location: $url");

    now obviously if I let anyone else use this theme, and they’re not installed in /empire, it won’t work

    I’ve been trying to figure this out and came across get_site_url

    Does it work for this? I see under scheme that admin is an option? Since I have no idea after reading the documentation, figured I’d ask!


    $url = get_bloginfo('url') . '/empire/wp-admin/admin.php?page=functions.php';

    Become something like:

    $url = get_site_url('', '', 'admin') . '?page=functions.php';

    or something like that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • You could try get_home_url rather than get_site_url:

    doesn’t that just get me to the home url of the site?

    Actually, you need a function to reliably get the admin URL, rather than the home URL and try to build a path to the admin. There is a new function in WordPress 3.0.0 get_admin_url which is basically a wrapper around get_site_url and it gives you a real easy way to grab the admin url.

    You can then use this in place of your currently hard coded value.

    Just try:

    echo get_admin_url();

    and see what it renders to the screen.

    yessir, that’s exactly what I need! Thanks,!

    Your welcome! Glad it worked.. 🙂

    me too! There is pretty much no reference to that that can be found easily on codex or google…. I exhausted my google-fu trying to find that exact function!

    Most new features (3.0 +) are not THAT well documented unfortunately, they take time to permeate through..

    Some have gotten a lot of coverage such as custom post types, multisite/network etc. but not all.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘how to get admin url? get_site_url?’ is closed to new replies.