admin_url()
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.
Uses: get_admin_url()
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
#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/
#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() admin url code WP 6.8
function admin_url( $path = '', $scheme = 'admin' ) { return get_admin_url( null, $path, $scheme ); }