WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to get admin url? get_site_url? (8 posts)

  1. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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!

    Does

    $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?

  2. David Gwyer
    Member
    Posted 3 years ago #

    You could try get_home_url rather than get_site_url:

    http://codex.wordpress.org/Template_Tags/get_home_url

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

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

  4. David Gwyer
    Member
    Posted 3 years ago #

    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.

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

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

  6. David Gwyer
    Member
    Posted 3 years ago #

    Your welcome! Glad it worked.. :)

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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!

  8. David Gwyer
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic