4

basically need to change the value that - admin_url() returns any idea?

1 Answer 1

10

This function is defined in wp-includes/link-template.php, and it offers a filter:

/**
 * Retrieve the url to the admin area.
 *
 * @package WordPress
 * @since 2.6.0
 *
 * @param string $path Optional path relative to the admin url
 * @return string Admin url link with optional path appended
*/
function admin_url($path = '') {
    $url = site_url('wp-admin/', 'admin');

    if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
        $url .= ltrim($path, '/');

    return apply_filters('admin_url', $url, $path);
}

So you can control the output with an own filter function in your themes functions.php:

add_filter('admin_url', 'my_new_admin_url');

function my_new_admin_url()
{
    // Insert the new URL here:
    return 'http://example.org/boss/';
}

Now hope that all plugin authors use this function and not an hard coded path … :)

Addendum

Add this line to your .htaccess:

Redirect permanent /wp-admin/ http://example.org/new_url/
3
  • <blockquote>Now hope that all plugin authors use this function and not an hard coded path</blockquote> i agree with you. But the hardcoded one can be use when you need to make backward compability
    – justjoe
    Apr 6, 2010 at 13:31
  • Even Wordpress doesn't seem to respect the filter - if you move that folder you'll get errors like Warning: require_once(/public_html/wp-admin/includes/bookmark.php) [function.require-once]: failed to open stream: No such file or directory in /public_html/app-admin/includes/admin.php on line 10 (right from the core WP folder)
    – Brian Hogg
    May 22, 2012 at 1:58
  • The wp-admin filesystem path is NOT meant to be changed. However, the admin URL can be changed and mapped to the internal directory path via a server config directive or filesystem link.
    – Kris
    Jan 21, 2017 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.