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

Is there a better way of retrieving the path of admin.php and the url of wp-admin.css?

What I can think of is:

$adminphppath = ABSPATH . '\wp-admin\admin.php';
$admincssurl = get_bloginfo('wpurl') . '/wp-admin/css/wp-admin.css";

But, some may be changing the admin path for security. So I need a more reliable way.

[Edit] I need the system path for admin.php, not url. Because I need to include it.

share|improve this question
You cannot change the wp-admin folder name. You can rewrite it url wise but it ain't going to make anything more secure. – Wyck Aug 20 '12 at 3:30
So is ABSPATH the most reliable way? – Teno Aug 20 '12 at 5:17
yes, yes it is. – Wyck Aug 20 '12 at 5:31
up vote 6 down vote accepted

You can use admin_url() function for wp-admin.css file and ABSPATH for admin.php.

$admin_php_path = ABSPATH . '/wp-admin/admin.php';
$admin_css_url = admin_url( 'css/wp-admin.css' );
share|improve this answer
For the css file it works thanks but for admin.php, actually I need to use include() so I need the system path, not the url. If I include with url, I get Warning: require() [function.require]: http:// wrapper is disabled in the server configuration by allow_url_include=0 – Teno Aug 20 '12 at 2:59
O, sorry about that. admin_url() will return URL which is useless with require or include, so as @Wyck said you should use ABSPATH. Updated answer. – Mamaduka Aug 20 '12 at 7:43

Old question I know, but this accounts for installs where wp-admin is not the admin directory

$admin_abspath = str_replace( site_url(), ABSPATH, admin_url() );
$admin_php_path = $admin_abspath . '/wp-admin/admin.php';
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.