admin_url()WP 2.6.0

Retrieves the URL to the admin area for the current site. Takes into account protocols (http and https).

To get a link to the network admin panel page, use the network_admin_url() function.

1 time — 0.001915 sec (very slow) | 50000 times — 2.76 sec (fast) | PHP 7.1.2, WP 4.7.4

No Hooks.

Return

String. Admin URL link with optional path appended.

Usage

admin_url( $path, $scheme );
$path(string)
Optional path relative to the admin URL.
Default: ''
$scheme(string)

The scheme (protocol) can be passed to force those schemes.

  • http - specify the Protocol forcibly.
  • https - specify the Protocol forcibly.
  • relative - return relative URL (without domain).

Default: 'admin'

Examples

0

#1 Demonstration of what the function retrieve

The Protocol will be changed automatically if necessary.

$url = admin_url();
echo $url; //> http://example.com/wp-admin/
0

#2 Get a link to a specific admin page

Posts > Categories and force https scheme:

$url = admin_url( 'edit-tags.php?taxonomy=category', 'https' );
echo $url; //> https://site.com/wp-admin/edit-tags.php?taxonomy=category

Changelog

Since 2.6.0 Introduced.

admin_url() code WP 6.4.3

function admin_url( $path = '', $scheme = 'admin' ) {
	return get_admin_url( null, $path, $scheme );
}