admin_url() WordPress Function

The admin_url() function is a built-in function in WordPress that retrieves the URL to the admin area for the current site. It is a safe way to get the URL to the admin area of a WordPress site, regardless of the WordPress version or settings.

admin_url( string $path = '', string $scheme = 'admin' ) #

Retrieves the URL to the admin area for the current site.


Parameters

$path

(string)(Optional) Path relative to the admin URL. Default 'admin'.

Default value: ''

$scheme

(string)(Optional)The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.

Default value: 'admin'


Top ↑

Return

(string) Admin URL link with optional path appended.


Top ↑

Source

File: wp-includes/link-template.php

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


Top ↑

Changelog

Changelog
VersionDescription
2.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More